Skip to content
Closed
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
38 changes: 31 additions & 7 deletions docling/datamodel/pipeline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ConfigDict,
Field,
)
from typing_extensions import deprecated
from typing_extensions import Annotated, deprecated

from docling.datamodel import asr_model_specs, vlm_model_specs

Expand Down Expand Up @@ -79,18 +79,42 @@ class TableStructureOptions(BaseTableStructureOptions):
class OcrOptions(BaseOptions):
"""OCR options."""

lang: List[str]
force_full_page_ocr: bool = False # If enabled a full page OCR is always applied
bitmap_area_threshold: float = (
0.05 # percentage of the area for a bitmap to processed with OCR
)
lang: Annotated[
List[str],
Field(
description="List of OCR languages to use, in ISO codes (e.g., 'deu', 'eng').",
examples=[["deu", "eng"]],
),
]

force_full_page_ocr: Annotated[
bool,
Field(
description="If enabled, a full-page OCR is always applied.",
examples=[False],
),
] = False

bitmap_area_threshold: Annotated[
float,
Field(
description="Percentage of the page area for a bitmap to be processed with OCR.",
examples=[0.05, 0.1],
),
] = 0.05


class OcrAutoOptions(OcrOptions):
"""Options for pick OCR engine automatically."""

kind: ClassVar[Literal["auto"]] = "auto"
lang: List[str] = []
lang: Annotated[
List[str],
Field(
description="Default value is an empty list, i.e. no language selected",
examples=["eng", "deu"],
),
] = []


class RapidOcrOptions(OcrOptions):
Expand Down