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,3 +1,22 @@
# %% [markdown]
# Run conversion with an explicit accelerator configuration (CPU/MPS/CUDA).
#
# What this example does
# - Shows how to select the accelerator device and thread count.
# - Enables OCR and table structure to exercise compute paths, and prints timings.
#
# How to run
# - From the repo root: `python docs/examples/run_with_accelerator.py`.
# - Toggle the commented `AcceleratorOptions` examples to try AUTO/MPS/CUDA.
#
# Notes
# - EasyOCR does not support `cuda:N` device selection (defaults to `cuda:0`).
# - `settings.debug.profile_pipeline_timings = True` prints profiling details.
# - `AcceleratorDevice.MPS` is macOS-only; `CUDA` requires a compatible GPU and
# CUDA-enabled PyTorch build. CPU mode works everywhere.
# %%
from pathlib import Path
from docling.datamodel.accelerator_options import AcceleratorDevice, AcceleratorOptions