Florent Gbelidji commited on
Sync DeepSeek OCR HF job code
Browse files- ds_batch_ocr/document.py +2 -2
- ds_batch_ocr/stages.py +3 -1
ds_batch_ocr/document.py
CHANGED
|
@@ -101,8 +101,8 @@ def save_figure(
|
|
| 101 |
return FigureMetadata(
|
| 102 |
figure_id=figure_id,
|
| 103 |
label=label,
|
| 104 |
-
image_path=(Path(sample_id) / figure_relative_doc_path).
|
| 105 |
-
document_relative_path=figure_relative_doc_path.
|
| 106 |
bounding_box_pixels=bounding_box_pixels,
|
| 107 |
)
|
| 108 |
|
|
|
|
| 101 |
return FigureMetadata(
|
| 102 |
figure_id=figure_id,
|
| 103 |
label=label,
|
| 104 |
+
image_path=(Path(sample_id) / figure_relative_doc_path).as_str(),
|
| 105 |
+
document_relative_path=figure_relative_doc_path.as_str(),
|
| 106 |
bounding_box_pixels=bounding_box_pixels,
|
| 107 |
)
|
| 108 |
|
ds_batch_ocr/stages.py
CHANGED
|
@@ -295,6 +295,8 @@ def run_stage_extract(settings: ExtractSettings) -> None:
|
|
| 295 |
|
| 296 |
#write document with boxes image to file
|
| 297 |
img_draw.save(ctx["sample_dir"] / "document_with_boxes.png")
|
|
|
|
|
|
|
| 298 |
|
| 299 |
#build document metadata
|
| 300 |
batch_document_dicts.append(
|
|
@@ -307,7 +309,7 @@ def run_stage_extract(settings: ExtractSettings) -> None:
|
|
| 307 |
"document_with_boxes_path": str(ctx["sample_dir"] / "document_with_boxes.png"),
|
| 308 |
"document_markdown_text": str(markdown),
|
| 309 |
"extracted_figures": [str(figure.image_path) for figure in figures],
|
| 310 |
-
"extracted_figures_metadata": [
|
| 311 |
}
|
| 312 |
)
|
| 313 |
|
|
|
|
| 295 |
|
| 296 |
#write document with boxes image to file
|
| 297 |
img_draw.save(ctx["sample_dir"] / "document_with_boxes.png")
|
| 298 |
+
|
| 299 |
+
|
| 300 |
|
| 301 |
#build document metadata
|
| 302 |
batch_document_dicts.append(
|
|
|
|
| 309 |
"document_with_boxes_path": str(ctx["sample_dir"] / "document_with_boxes.png"),
|
| 310 |
"document_markdown_text": str(markdown),
|
| 311 |
"extracted_figures": [str(figure.image_path) for figure in figures],
|
| 312 |
+
"extracted_figures_metadata": [asdict(figure) for figure in figures],
|
| 313 |
}
|
| 314 |
)
|
| 315 |
|