From 517230b9c45e60e900fb334922617578726eab14 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Tue, 8 Jul 2025 13:07:56 +0200 Subject: [PATCH] Updated naming Signed-off-by: Christoph Auer --- docling/datamodel/layout_model_specs.py | 15 +++++++-------- docling/datamodel/pipeline_options.py | 14 +++++++------- docling/models/layout_model.py | 6 +++--- docling/pipeline/standard_pdf_pipeline.py | 3 --- docling/utils/model_downloader.py | 4 ++-- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/docling/datamodel/layout_model_specs.py b/docling/datamodel/layout_model_specs.py index 08d5cd50..491d82df 100644 --- a/docling/datamodel/layout_model_specs.py +++ b/docling/datamodel/layout_model_specs.py @@ -29,42 +29,42 @@ class LayoutModelConfig(BaseModel): # HuggingFace Layout Models # Default Docling Layout Model -DOCLING_LAYOUT_V2 = LayoutModelConfig( - name="docling_layout_old", +docling_layout_v2 = LayoutModelConfig( + name="docling_layout_v2", repo_id="ds4sd/docling-layout-old", revision="main", model_path="", ) -DOCLING_LAYOUT_HERON = LayoutModelConfig( +docling_layout_heron = LayoutModelConfig( name="docling_layout_heron", repo_id="ds4sd/docling-layout-heron", revision="main", model_path="", ) -DOCLING_LAYOUT_HERON_101 = LayoutModelConfig( +docling_layout_heron_101 = LayoutModelConfig( name="docling_layout_heron_101", repo_id="ds4sd/docling-layout-heron-101", revision="main", model_path="", ) -DOCLING_LAYOUT_EGRET_MEDIUM = LayoutModelConfig( +docling_layout_egret_medium = LayoutModelConfig( name="docling_layout_egret_medium", repo_id="ds4sd/docling-layout-egret-medium", revision="main", model_path="", ) -DOCLING_LAYOUT_EGRET_LARGE = LayoutModelConfig( +docling_layout_egret_large = LayoutModelConfig( name="docling_layout_egret_large", repo_id="ds4sd/docling-layout-egret-large", revision="main", model_path="", ) -DOCLING_LAYOUT_EGRET_XLARGE = LayoutModelConfig( +docling_layout_egret_xlarge = LayoutModelConfig( name="docling_layout_egret_xlarge", repo_id="ds4sd/docling-layout-egret-xlarge", revision="main", @@ -82,7 +82,6 @@ DOCLING_LAYOUT_EGRET_XLARGE = LayoutModelConfig( class LayoutModelType(str, Enum): DOCLING_LAYOUT_V2 = "docling_layout_v2" - DOCLING_LAYOUT_OLD = "docling_layout_old" DOCLING_LAYOUT_HERON = "docling_layout_heron" DOCLING_LAYOUT_HERON_101 = "docling_layout_heron_101" DOCLING_LAYOUT_EGRET_MEDIUM = "docling_layout_egret_medium" diff --git a/docling/datamodel/pipeline_options.py b/docling/datamodel/pipeline_options.py index b4573384..fec3db76 100644 --- a/docling/datamodel/pipeline_options.py +++ b/docling/datamodel/pipeline_options.py @@ -17,13 +17,13 @@ from docling.datamodel import asr_model_specs # Import the following for backwards compatibility from docling.datamodel.accelerator_options import AcceleratorDevice, AcceleratorOptions from docling.datamodel.layout_model_specs import ( - DOCLING_LAYOUT_EGRET_LARGE, - DOCLING_LAYOUT_EGRET_MEDIUM, - DOCLING_LAYOUT_EGRET_XLARGE, - DOCLING_LAYOUT_HERON, - DOCLING_LAYOUT_HERON_101, - DOCLING_LAYOUT_V2, LayoutModelConfig, + docling_layout_egret_large, + docling_layout_egret_medium, + docling_layout_egret_xlarge, + docling_layout_heron, + docling_layout_heron_101, + docling_layout_v2, ) from docling.datamodel.pipeline_options_asr_model import ( InlineAsrOptions, @@ -279,7 +279,7 @@ class LayoutOptions(BaseModel): """Options for layout processing.""" create_orphan_clusters: bool = True # Whether to create clusters for orphaned cells - model: LayoutModelConfig = DOCLING_LAYOUT_V2 + model_spec: LayoutModelConfig = docling_layout_v2 class AsrPipelineOptions(PipelineOptions): diff --git a/docling/models/layout_model.py b/docling/models/layout_model.py index fdd5701f..fbe04313 100644 --- a/docling/models/layout_model.py +++ b/docling/models/layout_model.py @@ -12,7 +12,7 @@ from PIL import Image from docling.datamodel.accelerator_options import AcceleratorOptions from docling.datamodel.base_models import BoundingBox, Cluster, LayoutPrediction, Page from docling.datamodel.document import ConversionResult -from docling.datamodel.layout_model_specs import DOCLING_LAYOUT_V2, LayoutModelConfig +from docling.datamodel.layout_model_specs import LayoutModelConfig, docling_layout_v2 from docling.datamodel.pipeline_options import LayoutOptions from docling.datamodel.settings import settings from docling.models.base_model import BasePageModel @@ -57,7 +57,7 @@ class LayoutModel(BasePageModel): self.options = options device = decide_device(accelerator_options.device) - layout_model_config = options.model + layout_model_config = options.model_spec model_repo_folder = layout_model_config.model_repo_folder model_path = layout_model_config.model_path @@ -91,7 +91,7 @@ class LayoutModel(BasePageModel): local_dir: Optional[Path] = None, force: bool = False, progress: bool = False, - layout_model_config: LayoutModelConfig = DOCLING_LAYOUT_V2, + layout_model_config: LayoutModelConfig = docling_layout_v2, ) -> Path: return download_hf_model( repo_id=layout_model_config.repo_id, diff --git a/docling/pipeline/standard_pdf_pipeline.py b/docling/pipeline/standard_pdf_pipeline.py index b00a9ad7..c04ddca9 100644 --- a/docling/pipeline/standard_pdf_pipeline.py +++ b/docling/pipeline/standard_pdf_pipeline.py @@ -37,9 +37,6 @@ _log = logging.getLogger(__name__) class StandardPdfPipeline(PaginatedPipeline): - # _layout_model_path = LayoutModel._model_path - # _table_model_path = TableStructureModel._model_path - def __init__(self, pipeline_options: PdfPipelineOptions): super().__init__(pipeline_options) self.pipeline_options: PdfPipelineOptions diff --git a/docling/utils/model_downloader.py b/docling/utils/model_downloader.py index a2994fb7..b93efc83 100644 --- a/docling/utils/model_downloader.py +++ b/docling/utils/model_downloader.py @@ -2,7 +2,7 @@ import logging from pathlib import Path from typing import Optional -from docling.datamodel.layout_model_specs import DOCLING_LAYOUT_V2 +from docling.datamodel.layout_model_specs import docling_layout_v2 from docling.datamodel.pipeline_options import ( granite_picture_description, smolvlm_picture_description, @@ -47,7 +47,7 @@ def download_models( if with_layout: _log.info("Downloading layout model...") LayoutModel.download_models( - local_dir=output_dir / DOCLING_LAYOUT_V2.model_repo_folder, + local_dir=output_dir / docling_layout_v2.model_repo_folder, force=force, progress=progress, )