|
13 | 13 | VlmPipelineOptions, |
14 | 14 | ) |
15 | 15 | from docling.pipeline.vlm_pipeline import VlmPipeline |
16 | | -from docling_core.types.doc import ImageRefMode |
| 16 | +from docling_core.types.doc import ImageRefMode, PictureClassificationLabel |
17 | 17 |
|
18 | 18 | from docling_jobkit.convert.manager import ( |
19 | 19 | DoclingConverterManager, |
|
24 | 24 | from docling_jobkit.datamodel.convert import ( |
25 | 25 | ConvertDocumentsOptions, |
26 | 26 | PictureDescriptionApi, |
| 27 | + PictureDescriptionLocal, |
27 | 28 | ) |
28 | 29 |
|
29 | 30 |
|
@@ -281,6 +282,48 @@ def test_options_cache_key_with_presets(): |
281 | 282 | hashes.add(hash) |
282 | 283 |
|
283 | 284 |
|
| 285 | +def test_legacy_picture_description_filters_reach_pipeline_options(): |
| 286 | + m = DoclingConverterManager(config=DoclingConverterManagerConfig()) |
| 287 | + |
| 288 | + with pytest.warns(DeprecationWarning): |
| 289 | + opts = ConvertDocumentsOptions( |
| 290 | + do_picture_description=True, |
| 291 | + picture_description_local=PictureDescriptionLocal( |
| 292 | + repo_id="HuggingFaceTB/SmolVLM-256M-Instruct", |
| 293 | + classification_allow=[PictureClassificationLabel.BAR_CHART], |
| 294 | + classification_deny=[PictureClassificationLabel.LOGO], |
| 295 | + classification_min_confidence=0.55, |
| 296 | + ), |
| 297 | + ) |
| 298 | + |
| 299 | + pipeline_opts = m.get_pdf_pipeline_opts(opts) |
| 300 | + picture_opts = pipeline_opts.pipeline_options.picture_description_options |
| 301 | + |
| 302 | + assert picture_opts.classification_allow == [PictureClassificationLabel.BAR_CHART] |
| 303 | + assert picture_opts.classification_deny == [PictureClassificationLabel.LOGO] |
| 304 | + assert picture_opts.classification_min_confidence == 0.55 |
| 305 | + |
| 306 | + |
| 307 | +def test_legacy_picture_description_api_filters_reach_pipeline_options(): |
| 308 | + m = DoclingConverterManager(config=DoclingConverterManagerConfig()) |
| 309 | + |
| 310 | + with pytest.warns(DeprecationWarning): |
| 311 | + opts = ConvertDocumentsOptions( |
| 312 | + do_picture_description=True, |
| 313 | + picture_description_api={ |
| 314 | + "url": "http://localhost", |
| 315 | + "classification_allow": ["map"], |
| 316 | + "classification_min_confidence": 0.8, |
| 317 | + }, |
| 318 | + ) |
| 319 | + |
| 320 | + pipeline_opts = m.get_pdf_pipeline_opts(opts) |
| 321 | + picture_opts = pipeline_opts.pipeline_options.picture_description_options |
| 322 | + |
| 323 | + assert [label.value for label in picture_opts.classification_allow] == ["map"] |
| 324 | + assert picture_opts.classification_min_confidence == 0.8 |
| 325 | + |
| 326 | + |
284 | 327 | def test_image_pipeline_uses_vlm_pipeline_when_requested(): |
285 | 328 | m = DoclingConverterManager(config=DoclingConverterManagerConfig()) |
286 | 329 | opts = ConvertDocumentsOptions(pipeline=ProcessingPipeline.VLM) |
|
0 commit comments