Skip to content
Merged
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
43 changes: 43 additions & 0 deletions tests/test_ocr_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from docling_eval.cli.main import evaluate, visualize
from docling_eval.datamodels.types import BenchMarkNames, EvaluationModality
from docling_eval.dataset_builders.pixparse_builder import PixparseDatasetBuilder
from docling_eval.dataset_builders.xfund_builder import XFUNDDatasetBuilder
from docling_eval.prediction_providers.google_prediction_provider import (
GoogleDocAIPredictionProvider,
)
Expand Down Expand Up @@ -55,3 +56,45 @@ def test_run_pixparse_builder():
idir=target_path / "eval_dataset",
odir=target_path / "evaluations" / EvaluationModality.OCR.value,
)


@pytest.mark.skipif(
IS_CI, reason="Skipping test in CI because the dataset is too heavy."
)
def test_run_xfund_builder():
target_path = Path(f"./scratch/{BenchMarkNames.XFUND.value}_google/")
google_provider = GoogleDocAIPredictionProvider(
do_visualization=True, ignore_missing_predictions=False
)

dataset = XFUNDDatasetBuilder(
dataset_source=target_path / "input_dataset",
target=target_path / "gt_dataset",
end_index=2,
)

dataset.retrieve_input_dataset()
dataset.save_to_disk() # does all the job of iterating the dataset, making GT+prediction records, and saving them in shards as parquet.

google_provider.create_prediction_dataset(
name=dataset.name,
gt_dataset_dir=target_path / "gt_dataset",
split="val", # NOTE: Xfund has val split instead of test
target_dataset_dir=target_path / "eval_dataset",
)

evaluate(
modality=EvaluationModality.OCR,
benchmark=BenchMarkNames.XFUND,
idir=target_path / "eval_dataset",
odir=target_path / "evaluations" / EvaluationModality.OCR.value,
split="val",
)

visualize(
modality=EvaluationModality.OCR,
benchmark=BenchMarkNames.XFUND,
idir=target_path / "eval_dataset",
odir=target_path / "evaluations" / EvaluationModality.OCR.value,
split="val",
)