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:
Mingxuan Zhao
2025-09-16 10:00:38 -04:00
committed by GitHub
parent 0e95171dd6
commit ff351fd40c
21 changed files with 608 additions and 85 deletions

View File

@@ -1,6 +1,21 @@
# WARNING
# This example demonstrates only how to develop a new enrichment model.
# It does not run the actual formula understanding model.
# %% [markdown]
# Developing an enrichment model example (formula understanding: scaffold only).
#
# What this example does
# - Shows how to define pipeline options, an enrichment model, and extend a pipeline.
# - Displays cropped images of formula items and yields them back unchanged.
#
# Important
# - This is a development scaffold; it does not run a real formula understanding model.
#
# How to run
# - From the repo root: `python docs/examples/develop_formula_understanding.py`.
#
# Notes
# - Set `do_formula_understanding=True` to enable the example enrichment stage.
# - Extends `StandardPdfPipeline` and keeps the backend when enrichment is enabled.
# %%
import logging
from collections.abc import Iterable
@@ -42,6 +57,8 @@ class ExampleFormulaUnderstandingEnrichmentModel(BaseItemAndImageEnrichmentModel
return
for enrich_element in element_batch:
# Opens a window for each cropped formula image; comment this out when
# running headless or processing many items to avoid blocking spam.
enrich_element.image.show()
yield enrich_element.item