管道选项
管道选项允许在转换管道期间自定义模型的执行。这包括OCR引擎、表格模型以及可以通过 do_xyz = True 启用的增值选项。
这是Docling中所有可用管道选项的自动生成API参考。
管道选项
类:
-
AcceleratorDevice–用于运行模型推断的设备
-
AcceleratorOptions– -
EasyOcrOptions–EasyOCR引擎的选项。
-
OcrEngine–有效的OCR引擎的枚举。
-
OcrMacOptions–Mac OCR 引擎的选项。
-
OcrOptions–OCR 选项。
-
PdfBackend–有效PDF后端的枚举。
-
PdfPipelineOptions–PDF管道的选项。
-
PictureDescriptionApiOptions– -
PictureDescriptionBaseOptions– -
PictureDescriptionVlmOptions– -
PipelineOptions–基础管道选项。
-
RapidOcrOptions–RapidOCR引擎的选项。
-
TableFormerMode–TableFormer模型的模式。
-
TableStructureOptions–表结构选项。
-
TesseractCliOcrOptions–TesseractCli引擎的选项。
-
TesseractOcrOptions–Tesseract引擎的选项。
属性:
花岗岩_图片_描述
模块-属性
granite_picture_description = PictureDescriptionVlmOptions(
repo_id="ibm-granite/granite-vision-3.1-2b-preview",
prompt="What is shown in this image?",
)
smolvlm_picture_description
module-attribute
smolvlm_picture_description = PictureDescriptionVlmOptions(
repo_id="HuggingFaceTB/SmolVLM-256M-Instruct"
)
加速器设备
加速器选项
基类: BaseSettings
方法:
-
check_alternative_envvars–从 "alternative" 环境变量 OMP_NUM_THREADS 设置 num_threads。
-
validate_device–
属性:
-
device(Union[str, AcceleratorDevice]) – -
model_config– -
num_threads(int) –
模型配置
类属性
实例属性
model_config = SettingsConfigDict(
env_prefix="DOCLING_",
env_nested_delimiter="_",
populate_by_name=True,
)
num_threads
类属性
实例属性
num_threads: int = 4
check_alternative_envvars
classmethod
check_alternative_envvars(data: Any) -> Any
将 num_threads 设置为 "alternative" 环境变量 OMP_NUM_THREADS。只有在其有效且常规环境变量未设置的情况下,才使用替代环境变量。
注意:标准的pydantic设置机制使用参数“aliases”并不提供相同的功能。如果别名环境变量被设置,并且用户尝试在设置初始化时覆盖该参数,Pydantic将提供的参数视为额外输入,而不是简单地覆盖该参数的环境变量值。
validate_device
validate_device(value)
EasyOcrOptions
基类: OcrOptions
EasyOCR引擎的选项。
属性:
-
bitmap_area_threshold(float) – -
confidence_threshold(float) – -
download_enabled(bool) – -
force_full_page_ocr(bool) – -
kind(Literal['easyocr']) – -
lang(List[str]) – -
model_config– -
model_storage_directory(可选[str]) – -
recog_network(可选[str]) – -
use_gpu(可选[bool]) –
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.05
置信度阈值
类属性
实例属性
confidence_threshold: float = 0.5
下载启用
类属性
实例属性
download_enabled: bool = True
force_full_page_ocr
类属性
实例属性
force_full_page_ocr: bool = False
类型
类属性
实例属性
kind: Literal['easyocr'] = 'easyocr'
语言
类属性
实例属性
lang: List[str] = ['fr', 'de', 'es', 'en']
模型配置
类属性
实例属性
model_config = ConfigDict(
extra="forbid", protected_namespaces=()
)
模型存储目录
类属性
实例属性
model_storage_directory: Optional[str] = None
recog_network
类属性
实例属性
recog_network: Optional[str] = 'standard'
使用_gpu
类属性
实例属性
use_gpu: Optional[bool] = None
OcrEngine
基类: str, Enum
有效OCR引擎的枚举。
属性:
-
EASYOCR– -
OCRMAC– -
RAPIDOCR– -
TESSERACT– -
TESSERACT_CLI–
EASYOCR
类属性
实例属性
EASYOCR = 'easyocr'
OCRMAC
类属性
实例属性
OCRMAC = 'ocrmac'
RAPIDOCR
类属性
实例属性
RAPIDOCR = 'rapidocr'
TESSERACT
类属性
实例属性
TESSERACT = 'tesseract'
TESSERACT_CLI
类属性
实例属性
TESSERACT_CLI = 'tesseract_cli'
OcrMacOptions
基类: OcrOptions
Mac OCR 引擎的选项。
属性:
-
bitmap_area_threshold(float) – -
force_full_page_ocr(bool) – -
framework(str) – -
kind(Literal['ocrmac']) – -
lang(List[str]) – -
model_config– -
识别(str) –
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.05
force_full_page_ocr
类属性
实例属性
force_full_page_ocr: bool = False
框架
类属性
实例属性
framework: str = 'vision'
类型
类属性
实例属性
kind: Literal['ocrmac'] = 'ocrmac'
语言
类属性
实例属性
lang: List[str] = ['fr-FR', 'de-DE', 'es-ES', 'en-US']
模型配置
类属性
实例属性
model_config = ConfigDict(extra='forbid')
识别
类属性
实例属性
recognition: str = 'accurate'
OcrOptions
基础: BaseModel
OCR 选项。
属性:
-
bitmap_area_threshold(float) – -
force_full_page_ocr(bool) – -
kind(str) – -
lang(List[str]) –
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.05
force_full_page_ocr
类属性
实例属性
force_full_page_ocr: bool = False
种类
实例属性
kind: str
语言
实例属性
lang: List[str]
PdfBackend
基类: str, Enum
有效PDF后端的枚举。
属性:
-
DLPARSE_V1– -
DLPARSE_V2– -
PYPDFIUM2–
DLPARSE_V1
类属性
实例属性
DLPARSE_V1 = 'dlparse_v1'
DLPARSE_V2
类属性
实例属性
DLPARSE_V2 = 'dlparse_v2'
PYPDFIUM2
类属性
实例属性
PYPDFIUM2 = 'pypdfium2'
PdfPipelineOptions
基类: PipelineOptions
PDF管道的选项。
属性:
-
accelerator_options(AcceleratorOptions) – -
artifacts_path(可选[联合[Path, str]]) – -
create_legacy_output(bool) – -
do_code_enrichment(bool) – -
do_formula_enrichment(bool) – -
do_ocr(bool) – -
do_picture_classification(bool) – -
do_picture_description(bool) – -
do_table_structure(bool) – -
document_timeout(可选[float]) – -
enable_remote_services(bool) – -
generate_page_images(bool) – -
generate_picture_images(bool) – -
generate_table_images(bool) – -
images_scale(float) – -
ocr_options(联合[EasyOcrOptions, TesseractCliOcrOptions, TesseractOcrOptions, OcrMacOptions, RapidOcrOptions]) – -
picture_description_options(已注释[联合[PictureDescriptionApiOptions, PictureDescriptionVlmOptions], 字段(区分符=kind)]) – -
table_structure_options(TableStructureOptions) –
artifacts_path
类属性
实例属性
artifacts_path: Optional[Union[Path, str]] = None
create_legacy_output
class-attribute
instance-attribute
create_legacy_output: bool = True
do_code_enrichment
类属性
实例属性
do_code_enrichment: bool = False
do_formula_enrichment
class-attribute
instance-attribute
do_formula_enrichment: bool = False
do_ocr
类属性
实例属性
do_ocr: bool = True
do_picture_classification
类属性
实例属性
do_picture_classification: bool = False
do_picture_description
类属性
实例属性
do_picture_description: bool = False
do_table_structure
类属性
实例属性
do_table_structure: bool = True
document_timeout
类属性
实例属性
document_timeout: Optional[float] = None
enable_remote_services
类属性
实例属性
enable_remote_services: bool = False
生成页面图像
类属性
实例属性
generate_page_images: bool = False
生成图片
类属性
实例属性
generate_picture_images: bool = False
生成表格图像
类属性
实例属性
generate_table_images: bool = Field(
default=False,
deprecated="Field `generate_table_images` is deprecated. To obtain table images, set `PdfPipelineOptions.generate_page_images = True` before conversion and then use the `TableItem.get_image` function.",
)
images_scale
类属性
实例属性
images_scale: float = 1.0
ocr_options
类属性
实例属性
ocr_options: Union[
EasyOcrOptions,
TesseractCliOcrOptions,
TesseractOcrOptions,
OcrMacOptions,
RapidOcrOptions,
] = Field(EasyOcrOptions(), discriminator="kind")
图片描述选项
类属性
实例属性
picture_description_options: Annotated[
Union[
PictureDescriptionApiOptions,
PictureDescriptionVlmOptions,
],
Field(discriminator=kind),
] = smolvlm_picture_description
table_structure_options
class-attribute
instance-attribute
table_structure_options: TableStructureOptions = (
TableStructureOptions()
)
图片描述API选项
基础: PictureDescriptionBaseOptions
属性:
-
batch_size(int) – -
bitmap_area_threshold(float) – -
headers(Dict[str, str]) – -
kind(Literal['api']) – -
params(Dict[str, Any]) – -
prompt(str) – -
来源(str) – -
scale(float) – -
timeout(float) – -
url(AnyUrl) –
batch_size
类属性
实例属性
batch_size: int = 8
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.2
标题
类属性
实例属性
headers: Dict[str, str] = {}
类型
类属性
实例属性
kind: Literal['api'] = 'api'
参数
类属性
实例属性
params: Dict[str, Any] = {}
提示
类属性
实例属性
prompt: str = 'Describe this image in a few sentences.'
来源
类属性
实例属性
provenance: str = ''
比例
类属性
实例属性
scale: float = 2
超时时间
类属性
实例属性
timeout: float = 20
网址
类属性
实例属性
url: AnyUrl = AnyUrl(
"http://localhost:8000/v1/chat/completions"
)
图片描述基本选项
基础: BaseModel
属性:
-
batch_size(int) – -
bitmap_area_threshold(float) – -
kind(str) – -
scale(float) –
batch_size
类属性
实例属性
batch_size: int = 8
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.2
种类
实例属性
kind: str
缩放
类属性
实例属性
scale: float = 2
图片描述Vlm选项
基础: PictureDescriptionBaseOptions
属性:
-
batch_size(int) – -
bitmap_area_threshold(float) – -
generation_config(Dict[str, Any]) – -
kind(Literal['vlm']) – -
prompt(str) – -
repo_cache_folder(str) – -
repo_id(str) – -
scale(float) –
batch_size
类属性
实例属性
batch_size: int = 8
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.2
generation_config
类属性
实例属性
generation_config: Dict[str, Any] = dict(
max_new_tokens=200, do_sample=False
)
类型
类属性
实例属性
kind: Literal['vlm'] = 'vlm'
提示
类属性
实例属性
prompt: str = 'Describe this image in a few sentences.'
repo_cache_folder
property
repo_cache_folder: str
repo_id
实例属性
repo_id: str
比例
类属性
实例属性
scale: float = 2
管道选项
基础: BaseModel
基础管道选项。
属性:
-
accelerator_options(AcceleratorOptions) – -
create_legacy_output(bool) – -
document_timeout(可选[float]) – -
enable_remote_services(bool) –
create_legacy_output
class-attribute
instance-attribute
create_legacy_output: bool = True
document_timeout
类属性
实例属性
document_timeout: Optional[float] = None
enable_remote_services
类属性
实例属性
enable_remote_services: bool = False
RapidOcrOptions
基类: OcrOptions
RapidOCR引擎的选项。
属性:
-
bitmap_area_threshold(float) – -
cls_model_path(可选[str]) – -
det_model_path(可选[str]) – -
force_full_page_ocr(bool) – -
kind(Literal['rapidocr']) – -
lang(List[str]) – -
model_config– -
print_verbose(bool) – -
rec_keys_path(可选[str]) – -
rec_model_path(可选[str]) – -
text_score(float) – -
use_cls(可选[布尔]) – -
use_det(可选[布尔值]) – -
use_rec(可选[bool]) –
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.05
cls_model_path
类属性
实例属性
cls_model_path: Optional[str] = None
det_model_path
类属性
实例属性
det_model_path: Optional[str] = None
force_full_page_ocr
类属性
实例属性
force_full_page_ocr: bool = False
类型
类属性
实例属性
kind: Literal['rapidocr'] = 'rapidocr'
语言
类属性
实例属性
lang: List[str] = ['english', 'chinese']
模型配置
类属性
实例属性
model_config = ConfigDict(extra='forbid')
print_verbose
类属性
实例属性
print_verbose: bool = False
rec_keys_path
类属性
实例属性
rec_keys_path: Optional[str] = None
rec_model_path
类属性
实例属性
rec_model_path: Optional[str] = None
文本得分
类属性
实例属性
text_score: float = 0.5
use_cls
class-attribute
instance-attribute
use_cls: Optional[bool] = None
use_det
类属性
实例属性
use_det: Optional[bool] = None
use_rec
类属性
实例属性
use_rec: Optional[bool] = None
表单模式
表结构选项
基础: BaseModel
表结构的选项。
属性:
-
do_cell_matching(bool) – -
mode(TableFormerMode) –
do_cell_matching
class-attribute
instance-attribute
do_cell_matching: bool = True
TesseractCliOcrOptions
基类: OcrOptions
TesseractCli引擎的选项。
属性:
-
bitmap_area_threshold(float) – -
force_full_page_ocr(bool) – -
kind(Literal['tesseract']) – -
lang(List[str]) – -
model_config– -
path(可选[str]) – -
tesseract_cmd(str) –
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.05
force_full_page_ocr
类属性
实例属性
force_full_page_ocr: bool = False
类型
类属性
实例属性
kind: Literal['tesseract'] = 'tesseract'
语言
类属性
实例属性
lang: List[str] = ['fra', 'deu', 'spa', 'eng']
模型配置
类属性
实例属性
model_config = ConfigDict(extra='forbid')
路径
类属性
实例属性
path: Optional[str] = None
tesseract_cmd
类属性
实例属性
tesseract_cmd: str = 'tesseract'
TesseractOcrOptions
基类: OcrOptions
用于Tesseract引擎的选项。
属性:
-
bitmap_area_threshold(float) – -
force_full_page_ocr(bool) – -
kind(Literal['tesserocr']) – -
lang(List[str]) – -
model_config– -
path(可选[str]) –
位图区域阈值
类属性
实例属性
bitmap_area_threshold: float = 0.05
force_full_page_ocr
类属性
实例属性
force_full_page_ocr: bool = False
类型
类属性
实例属性
kind: Literal['tesserocr'] = 'tesserocr'
语言
类属性
实例属性
lang: List[str] = ['fra', 'deu', 'spa', 'eng']
模型配置
类属性
实例属性
model_config = ConfigDict(extra='forbid')
路径
类属性
实例属性
path: Optional[str] = None