def predict_single(self, page: DatabasePage) -> Result: pcgts = page.pcgts() import pickle staff_lines: List[Coords] = [] pcgts = pcgts for mr in pcgts.page.music_blocks(): for ml in mr.lines: staff_lines += [ pcgts.page.page_to_image_scale( s.coords, PageScaleReference.NORMALIZED) for s in ml.staff_lines ] with open( page.file('connected_components_norm', create_if_not_existing=True).local_path(), 'rb') as pkl: polys = extract_components( pickle.load(pkl), pcgts.page.page_to_image_scale(self.initial_line, PageScaleReference.NORMALIZED), staff_lines) polys = [ pcgts.page.image_to_page_scale(c, PageScaleReference.NORMALIZED) for c in polys ] return Result(polys)
def unprocessed(cls, page: DatabasePage) -> bool: return any([not page.file(f).exists() for f in files])