Document Figure Classification#
Overview#
DocumentPictureClassifier is the enrichment model responsible for classifying every PictureItem in a DoclingDocument into a fine-grained visual category. It is distinct from layout detection (which labels regions as PICTURE vs. TABLE, etc.) and from VLM-based description generation. Enabling it sets PictureItem.meta.classification on each processed picture .
Classification is triggered by setting do_picture_classification=True in PdfPipelineOptions (or ConvertPipelineOptions).
Two-Tier Storage Model#
Results are stored in two parallel locations:
| Location | Type | Notes |
|---|---|---|
PictureItem.meta.classification | PictureClassificationMetaField | Primary. List of PictureClassificationPrediction (class_name + confidence). get_main_prediction() returns the highest-confidence result. |
PictureItem.annotations | PictureClassificationData | Deprecated. Kept for backward compatibility via _keep_deprecated_annotations; scheduled for removal. |
PictureMeta (which holds classification) extends FloatingMeta and also holds molecule, tabular_chart, and code .
Engine Abstraction#
The classifier delegates inference to a pluggable BaseImageClassificationEngine . Three concrete implementations are registered by engine type :
| Engine type | Class | Use case |
|---|---|---|
onnxruntime | OnnxRuntimeImageClassificationEngine | Default; CPU/CUDA providers, configurable graph optimization |
transformers | TransformersImageClassificationEngine | PyTorch backend; supports MPS, optional torch.compile() |
api_kserve_v2 | ApiKserveV2ImageClassificationEngine | Remote HTTP/gRPC endpoint; requires enable_remote_services=True |
Each engine must implement three abstract methods :
initialize()— load model/allocate resourcespredict_batch(input_batch)→List[ImageClassificationEngineOutput]get_label_mapping()→Dict[int, str]
Engine selection and model coordinates are configured via DocumentPictureClassifierOptions, which wraps an ImageClassificationModelSpec defaulting to the IMAGE_CLASSIFICATION_DOCUMENT_FIGURE preset (pointing to docling-project/DocumentFigureClassifier-v2.5).
DocumentPictureClassifier Pipeline Integration#
The model class is DocumentPictureClassifier, which:
- Accepts only
PictureItemnodes (is_processable) . - Renders images at 2× scale (
images_scale = 2) . - Converts images to RGB and batches them into
ImageClassificationEngineInputobjects . - Calls
engine.predict_batch(), maps label IDs → names viaget_label_mapping(). - Writes
PictureClassificationMetaFieldintoitem.meta.classification.
The 26-Class Taxonomy (DocumentFigureClassifier-v2.5)#
The model is an EfficientNet-B0 fine-tuned on a subset of HuggingFace/finepdfs, trained on a dataset 10× larger than v2.0 . It accepts 224×224 RGB images and achieves 90.7% accuracy and 0.689 balanced accuracy on a held-out test set .
The 26 active labels, grouped by category, are defined in PictureClassificationLabel:
| Group | Labels |
|---|---|
| Charts | bar_chart, box_plot, flow_chart, line_chart, pie_chart, scatter_plot, table, other_chart |
| Images | photograph, full_page_image, page_thumbnail |
| Company / Document | logo, icon, bar_code, qr_code, signature, stamp |
| Engineering / Science | engineering_drawing, chemistry_structure |
| Screenshots | screenshot_from_computer, screenshot_from_manual |
| Geography | geographical_map, topographical_map |
| Other | calendar, crossword_puzzle, music, other |
Note: The model's ONNX label list does not include
other_chart; the enum also retains legacy labels (cad_drawing,heatmap,molecular_structure, etc.) for backward compatibility with older serialized documents.
Inference backends are available via both Transformers and ONNX Runtime as documented on the model card.
Key Source Files#
| File | Purpose |
|---|---|
docling/models/stages/picture_classifier/document_picture_classifier.py | Main model class — batching, engine calls, result storage |
docling/models/inference_engines/image_classification/base.py | Abstract engine interface + IO types |
docling/datamodel/picture_classification_options.py | DocumentPictureClassifierOptions + preset registration |
docling_core/types/doc/items/picture/meta.py | PictureMeta, PictureClassificationMetaField, PictureClassificationPrediction |
docling_core/types/doc/items/picture/classification.py | PictureClassificationData (deprecated annotation format) |
docling_core/types/doc/labels.py | PictureClassificationLabel enum |
| HuggingFace model card | Architecture, per-label metrics, ONNX/Transformers usage examples |
tests/test_document_picture_classifier.py | Integration tests |