Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions docling_eval/utils/coco_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def export_COCO(
extra_doc_label_to_valid_label_mapping: dict[
DocItemLabel, Optional[DocItemLabel]
],
source_doc_column: str = "GT",
use_pred_doc: bool = False, # If True the gt_doc is used, otherwise the pred_doc
):
r"""
Parameters
Expand Down Expand Up @@ -171,7 +171,7 @@ def export_COCO(
data_record = DatasetRecordWithPrediction.model_validate(data)
doc_id = data_record.doc_id

if data_record.predicted_doc is not None and source_doc_column == "pred":
if data_record.predicted_doc is not None and use_pred_doc:
doc = data_record.predicted_doc
_log.info("Dataset document to export: 'predicted_doc'")
else:
Expand Down Expand Up @@ -538,7 +538,7 @@ def main():
"--operation",
required=True,
type=str,
help="Operation to perform. One of ['coco']",
help="Operation to perform. One of ['coco_gt_doc', 'coco_pred_doc', 'predictions']",
)
parser.add_argument(
"-s",
Expand Down Expand Up @@ -576,7 +576,8 @@ def main():
exporter = DoclingEvalCOCOExporter(args.docling_eval_dir)

# Run the operation
if args.operation.upper() == "COCO":
op = args.operation.lower()
if op in ["coco_gt_doc", "coco_pred_doc"]:
# Mapping from the parquet document label to the valid docling labels
doc_label_to_valid_label_mapping: dict[DocItemLabel, DocItemLabel] = {
DocItemLabel.PAGE_FOOTER: DocItemLabel.TEXT,
Expand All @@ -591,8 +592,9 @@ def main():
"test",
args.save_dir,
doc_label_to_valid_label_mapping,
use_pred_doc="coco_pred_doc" == op,
)
elif args.operation.upper() == "predictions":
elif op == "predictions":
exporter.export_predictions_wrt_original_COCO(
"test",
args.save_dir,
Expand Down
Loading