mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 20:58:11 +00:00
docs: Describe examples (#2262)
* Update .py examples with clearer guidance, update out of date imports and calls Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com> * Fix minimal.py string error, fix ruff format error Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com> * fix more CI issues Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com> --------- Signed-off-by: Mingxuan Zhao <43148277+mingxzhao@users.noreply.github.com>
This commit is contained in:
23
docs/examples/develop_picture_enrichment.py
vendored
23
docs/examples/develop_picture_enrichment.py
vendored
@@ -1,6 +1,21 @@
|
||||
# WARNING
|
||||
# This example demonstrates only how to develop a new enrichment model.
|
||||
# It does not run the actual picture classifier model.
|
||||
# %% [markdown]
|
||||
# Developing a picture enrichment model (classifier scaffold only).
|
||||
#
|
||||
# What this example does
|
||||
# - Demonstrates how to implement an enrichment model that annotates pictures.
|
||||
# - Adds a dummy PictureClassificationData entry to each PictureItem.
|
||||
#
|
||||
# Important
|
||||
# - This is a scaffold for development; it does not run a real classifier.
|
||||
#
|
||||
# How to run
|
||||
# - From the repo root: `python docs/examples/develop_picture_enrichment.py`.
|
||||
#
|
||||
# Notes
|
||||
# - Enables picture image generation and sets `images_scale` to improve crops.
|
||||
# - Extends `StandardPdfPipeline` with a custom enrichment stage.
|
||||
|
||||
# %%
|
||||
|
||||
import logging
|
||||
from collections.abc import Iterable
|
||||
@@ -43,7 +58,7 @@ class ExamplePictureClassifierEnrichmentModel(BaseEnrichmentModel):
|
||||
assert isinstance(element, PictureItem)
|
||||
|
||||
# uncomment this to interactively visualize the image
|
||||
# element.get_image(doc).show()
|
||||
# element.get_image(doc).show() # may block; avoid in headless runs
|
||||
|
||||
element.annotations.append(
|
||||
PictureClassificationData(
|
||||
|
||||
Reference in New Issue
Block a user