Skip to content

设置 DocumentAI 模型

概述

当需要使用 OCR、版面分析、表格识别等 AI 能力时,需要先设置 DocumentAI 模型路径。

SetDocumentAIModel 接口支持传入 gpuID 参数,用于指定 AI 模型使用的 GPU 设备编号;当 gpuID-1 时,表示不启用 GPU。

设置 AI 模型实例数量

如果需要控制版面分析和表格识别模型实例数量,可调用对应接口设置模型实例数量。

使用自定义 AI 引擎(4.1.0+)

从 v4.1.0 起,您可以不再调用 SetDocumentAIModel,而通过 ConvertCallback 上的回调接入自己的 OCR / 版面分析 / 表格识别引擎。详见《使用自定义 AI 模型回调》章节。

示例

go
modelPath := "***"
compdf.SetDocumentAIModelCount(1, 1)
compdf.SetDocumentAIModel(modelPath, 0)