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 all( [len(l.symbols) == 0 for l in page.pcgts().page.all_music_lines()])
def unprocessed(cls, page: DatabasePage) -> bool: return len(page.pcgts().page.text_blocks()) == 0
def unprocessed(cls, page: DatabasePage) -> bool: if not page.pcgts(): return True return len(page.pcgts().page.annotations.connections) == 0