Files
docling-eval/tests/test_ocr_aws_funsd.py
a34f2649ab fix: update hyperscalers to support multiple image file types (#118)
* fix: update docling prediction provider to include word cells

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

* fix: missing parsed_page in set_word_cells method

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

* Update docling_eval/prediction_providers/docling_provider.py

Co-authored-by: Christoph Auer <60343111+cau-git@users.noreply.github.com>
Signed-off-by: samiuc <sami.ullah.chat@gmail.com>

* Update docling_eval/prediction_providers/docling_provider.py

Co-authored-by: Christoph Auer <60343111+cau-git@users.noreply.github.com>
Signed-off-by: samiuc <sami.ullah.chat@gmail.com>

* fix: conditionally populate word_cells in _set_word_cells method

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

* feat: Implement smart weighted character distribution for line text processing

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

* fix: remove redundant field validators

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

* refactor: replace BoundingBoxDict with BoundingBox

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

* refactor: update BoundingBox usage in prediction providers

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

* refactor: remove unused code

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

* refactor: move validate_evaluation_results to test_utils

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

---------

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>
Signed-off-by: samiuc <sami.ullah.chat@gmail.com>
Co-authored-by: samiullahchattha <Sami.Ullah1@ibm.com>
Co-authored-by: Christoph Auer <60343111+cau-git@users.noreply.github.com>
2025-07-01 12:17:50 -07:00

67 lines
2.1 KiB
Python

import logging
import os
from pathlib import Path
import pytest
from docling_eval.cli.main import evaluate, visualize
from docling_eval.datamodels.types import BenchMarkNames, EvaluationModality
from docling_eval.dataset_builders.funsd_builder import FUNSDDatasetBuilder
from docling_eval.prediction_providers.aws_prediction_provider import (
AWSTextractPredictionProvider,
)
from tests.test_utils import validate_evaluation_results
IS_CI = os.getenv("RUN_IN_CI") == "1"
logging.getLogger("botocore").setLevel(logging.WARNING)
logging.getLogger("PIL").setLevel(logging.WARNING)
logging.getLogger("matplotlib").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("filelock").setLevel(logging.WARNING)
@pytest.mark.skipif(
IS_CI, reason="Skipping test in CI because the dataset is too heavy."
)
def test_run_funsd_builder():
target_path = Path(f"./scratch/{BenchMarkNames.FUNSD.value}_aws/")
dataset_source = Path(target_path, "input_dataset")
aws_provider = AWSTextractPredictionProvider(
do_visualization=True, ignore_missing_predictions=False
)
dataset = FUNSDDatasetBuilder(
dataset_source=dataset_source,
target=target_path / "gt_dataset",
end_index=1,
)
dataset.retrieve_input_dataset()
dataset.save_to_disk()
aws_provider.create_prediction_dataset(
# name="Funsd",
name=dataset.name,
gt_dataset_dir=target_path / "gt_dataset",
target_dataset_dir=target_path / "eval_dataset",
)
evaluate(
modality=EvaluationModality.OCR,
benchmark=BenchMarkNames.FUNSD,
idir=target_path / "eval_dataset",
odir=target_path / "evaluations" / EvaluationModality.OCR.value,
)
validate_evaluation_results(
target_path=target_path,
benchmark=BenchMarkNames.FUNSD.value,
modality=EvaluationModality.OCR.value,
)
visualize(
modality=EvaluationModality.OCR,
benchmark=BenchMarkNames.FUNSD,
idir=target_path / "eval_dataset",
odir=target_path / "evaluations" / EvaluationModality.OCR.value,
)