Skip to content
ComPDF

Set DocumentAI Model

Overview

Before using OCR, Layout Analysis, Table Recognition you need to set the DocumentAI model path first.

set_document_ai_model supports an optional gpu_id parameter used to specify the GPU device index for the AI model. When gpu_id is -1, GPU acceleration is disabled.

Set AI Model Instance Count

If you need to control the number of Layout Analysis and Table Recognition model instances, call the corresponding interface to set the model instance counts.

Use Your Own AI Engine (SDK v4.1.0+)

This option is available only in SDK v4.1.0 or later. You can skip set_document_ai_model and plug in your own OCR, Layout Analysis, or Table Recognition engine through the callbacks on ConvertCallback. See 3.11 Use Custom AI Models via Callbacks for details.

Sample

python
model_path = "***"
LibraryManager.set_document_ai_model_count(1, 1)
LibraryManager.set_document_ai_model(model_path)