Files
docling-eval/docling_eval/evaluators/ocr/evaluation_models.py
17e9fde84f feat: Update OCREvaluator with additional metrics (#78)
* Add README for Docling-DPBench

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>

* feat: Update OCREvaluator with additional metrics

* fix: bug fix

* add edit-distance lib

* update pure ocr metrics

* Establish SegmentedPage support in DatasetRecord and DatasetRecordWithPrediction

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>

* Add SegmentedPage usage to PixParse dataset provider

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>

* add pure ocr metrics

* refactor: update dependencies

* fix dependencies and build errors

* feat: add optype and scipy-stubs packages

* fix: fix type error

* fix package name

* fix bugs and add funsd ocr test

* fix type error

* finalize changes

* fix build errors

* fix: ignore edit_distance missing import

* Add functionality to merge cells in Google OCR prediction (#103)

* feat: add global_merge function in google prediction provider for word cell merging

* address review comment

* remove unused imports

* address review comments and remove dictionary conversions

---------

Co-authored-by: samiullahchattha <Sami.Ullah1@ibm.com>

* refactor and address review comments

* fix regression bug

* refactor code and reduce metrics to three

* make ocr classes private

* fix type error

* refactor: update geometry utils to use BoundingBox and TextCell

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* refactor: rename metrics variables for consistency and clarity

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* Update lock for docling-core

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>

---------

Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
Signed-off-by: samiuc <sami.ullah.chat@gmail.com>
Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>
Co-authored-by: Christoph Auer <cau@zurich.ibm.com>
Co-authored-by: samiullahchattha <Sami.Ullah1@ibm.com>
2025-06-02 14:48:32 +02:00

75 lines
1.7 KiB
Python

from typing import Any, List, Optional
from docling_core.types.doc import BoundingBox
from docling_core.types.doc.page import TextCell
from pydantic import BaseModel, Field
class _CalculationConstants:
EPS: float = 1.0e-6
class Word(TextCell):
vertical: bool
polygon: List[List[float]]
matched: bool = Field(default=False)
ignore_zone: Optional[bool] = None
to_remove: Optional[bool] = None
@property
def bbox(self) -> BoundingBox:
return self.rect.to_bounding_box()
class BenchmarkIntersectionInfo(BaseModel):
x_axis_overlap: float
y_axis_overlap: float
intersection_area: float
union_area: float
iou: float
gt_box_portion_covered: float
prediction_box_portion_covered: float
x_axis_iou: Optional[float] = None
y_axis_iou: Optional[float] = None
class OcrMetricsSummary(BaseModel):
number_of_prediction_cells: int
number_of_gt_cells: int
number_of_false_positive_detections: int
number_of_true_positive_matches: int
number_of_false_negative_detections: int
detection_precision: float
detection_recall: float
detection_f1: float
class Config:
populate_by_name = True
class OcrBenchmarkEntry(BaseModel):
image_name: str
metrics: OcrMetricsSummary
class AggregatedBenchmarkMetrics(BaseModel):
f1: float = Field(alias="F1")
recall: float = Field(alias="Recall")
precision: float = Field(alias="Precision")
class Config:
populate_by_name = True
class DocumentEvaluationEntry(BaseModel):
doc_id: str
class Config:
extra = "allow"
class OcrDatasetEvaluationResult(BaseModel):
f1_score: float = 0.0
recall: float = 0.0
precision: float = 0.0