Skip to content

Commit b14ee15

Browse files
authored
refactor: organize models in submodules (#2845)
* refactor ocr models Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * refactor vlm api models Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * refactor vlm_models Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * refactor picture description Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * refactor table structure Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * refactor all into stages Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> --------- Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
1 parent 1d49872 commit b14ee15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+73
-43
lines changed

docling/experimental/pipeline/threaded_layout_vlm_pipeline.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
from docling.experimental.datamodel.threaded_layout_vlm_pipeline_options import (
3333
ThreadedLayoutVlmPipelineOptions,
3434
)
35-
from docling.models.api_vlm_model import ApiVlmModel
3635
from docling.models.base_model import BaseVlmPageModel
37-
from docling.models.layout_model import LayoutModel
38-
from docling.models.vlm_models_inline.hf_transformers_model import (
36+
from docling.models.stages.layout.layout_model import LayoutModel
37+
from docling.models.vlm_pipeline_models.api_vlm_model import ApiVlmModel
38+
from docling.models.vlm_pipeline_models.hf_transformers_model import (
3939
HuggingFaceTransformersVlmModel,
4040
)
41-
from docling.models.vlm_models_inline.mlx_model import HuggingFaceMlxModel
41+
from docling.models.vlm_pipeline_models.mlx_model import HuggingFaceMlxModel
4242
from docling.pipeline.base_pipeline import BasePipeline
4343
from docling.pipeline.standard_pdf_pipeline import (
4444
ProcessingResult,
@@ -162,7 +162,7 @@ def build_prompt(
162162
vlm_options=vlm_options,
163163
)
164164
elif vlm_options.inference_framework == InferenceFramework.VLLM:
165-
from docling.models.vlm_models_inline.vllm_model import VllmVlmModel
165+
from docling.models.vlm_pipeline_models.vllm_model import VllmVlmModel
166166

167167
self.vlm_model = VllmVlmModel(
168168
enabled=True,

docling/models/extraction/__init__.py

Whitespace-only changes.

docling/models/vlm_models_inline/nuextract_transformers_model.py renamed to docling/models/extraction/nuextract_transformers_model.py

File renamed without changes.

docling/models/plugins/defaults.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
def ocr_engines():
2-
from docling.models.auto_ocr_model import OcrAutoModel
3-
from docling.models.easyocr_model import EasyOcrModel
4-
from docling.models.ocr_mac_model import OcrMacModel
5-
from docling.models.rapid_ocr_model import RapidOcrModel
6-
from docling.models.tesseract_ocr_cli_model import TesseractOcrCliModel
7-
from docling.models.tesseract_ocr_model import TesseractOcrModel
2+
from docling.models.stages.ocr.auto_ocr_model import OcrAutoModel
3+
from docling.models.stages.ocr.easyocr_model import EasyOcrModel
4+
from docling.models.stages.ocr.ocr_mac_model import OcrMacModel
5+
from docling.models.stages.ocr.rapid_ocr_model import RapidOcrModel
6+
from docling.models.stages.ocr.tesseract_ocr_cli_model import TesseractOcrCliModel
7+
from docling.models.stages.ocr.tesseract_ocr_model import TesseractOcrModel
88

99
return {
1010
"ocr_engines": [
@@ -19,8 +19,12 @@ def ocr_engines():
1919

2020

2121
def picture_description():
22-
from docling.models.picture_description_api_model import PictureDescriptionApiModel
23-
from docling.models.picture_description_vlm_model import PictureDescriptionVlmModel
22+
from docling.models.stages.picture_description.picture_description_api_model import (
23+
PictureDescriptionApiModel,
24+
)
25+
from docling.models.stages.picture_description.picture_description_vlm_model import (
26+
PictureDescriptionVlmModel,
27+
)
2428

2529
return {
2630
"picture_description": [
@@ -34,7 +38,7 @@ def layout_engines():
3438
from docling.experimental.models.table_crops_layout_model import (
3539
TableCropsLayoutModel,
3640
)
37-
from docling.models.layout_model import LayoutModel
41+
from docling.models.stages.layout.layout_model import LayoutModel
3842

3943
return {
4044
"layout_engines": [
@@ -45,7 +49,9 @@ def layout_engines():
4549

4650

4751
def table_structure_engines():
48-
from docling.models.table_structure_model import TableStructureModel
52+
from docling.models.stages.table_structure.table_structure_model import (
53+
TableStructureModel,
54+
)
4955

5056
return {
5157
"table_structure_engines": [

docling/models/stages/__init__.py

Whitespace-only changes.

docling/models/stages/code_formula/__init__.py

Whitespace-only changes.
File renamed without changes.

docling/models/stages/layout/__init__.py

Whitespace-only changes.
File renamed without changes.

docling/models/stages/ocr/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)