Skip to content

Commit

Permalink
Fix class re-mapping for table of contents (#33)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Auer <[email protected]>
Co-authored-by: Christoph Auer <[email protected]>
  • Loading branch information
cau-git and cau-git authored Aug 14, 2024
1 parent dd0df9f commit 61be78a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docling/models/layout_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def postprocess(self, clusters: List[Cluster], cells: List[Cell], page_height):
"Key-Value Region": 0.45,
}

CLASS_REMAPPINGS = {
"Document Index": "Table",
}

_log.debug("================= Start postprocess function ====================")
start_time = time.time()
# Apply Confidence Threshold to cluster predictions
Expand All @@ -79,6 +83,10 @@ def postprocess(self, clusters: List[Cluster], cells: List[Cell], page_height):
confidence = CLASS_THRESHOLDS[cluster.label]
if cluster.confidence >= confidence:
# annotation["created_by"] = "high_conf_pred"

# Remap class labels where needed.
if cluster.label in CLASS_REMAPPINGS.keys():
cluster.label = CLASS_REMAPPINGS[cluster.label]
clusters_out.append(cluster)

# map to dictionary clusters and cells, with bottom left origin
Expand Down

0 comments on commit 61be78a

Please sign in to comment.