chore: Restore the orphan clusters

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
This commit is contained in:
Nikos Livathinos 2025-02-14 11:13:54 +01:00
parent e824996406
commit b5b1ddca3b

View File

@ -264,29 +264,26 @@ class LayoutPostprocessor:
# Remove clusters with no cells # Remove clusters with no cells
clusters = [cluster for cluster in clusters if cluster.cells] clusters = [cluster for cluster in clusters if cluster.cells]
########################################################################################### # Handle orphaned cells
# Debug unassigned = self._find_unassigned_cells(clusters)
# # Handle orphaned cells if unassigned:
# unassigned = self._find_unassigned_cells(clusters) next_id = max((c.id for c in clusters), default=0) + 1
# if unassigned: orphan_clusters = []
# next_id = max((c.id for c in clusters), default=0) + 1 for i, cell in enumerate(unassigned):
# orphan_clusters = [] conf = 1.0
# for i, cell in enumerate(unassigned): if isinstance(cell, OcrCell):
# conf = 1.0 conf = cell.confidence
# if isinstance(cell, OcrCell):
# conf = cell.confidence
# orphan_clusters.append( orphan_clusters.append(
# Cluster( Cluster(
# id=next_id + i, id=next_id + i,
# label=DocItemLabel.TEXT, label=DocItemLabel.TEXT,
# bbox=cell.bbox, bbox=cell.bbox,
# confidence=conf, confidence=conf,
# cells=[cell], cells=[cell],
# ) )
# ) )
# clusters.extend(orphan_clusters) clusters.extend(orphan_clusters)
###########################################################################################
# Iterative refinement # Iterative refinement
prev_count = len(clusters) + 1 prev_count = len(clusters) + 1