ONNX 模型库
返回模型

说明文档

🪄 自动将 PDF 转换为可填写表单。

💻 托管模型 | 📄 CommonForms 论文 | 🤗 数据集 | 🦾 模型

Pipeline

FFDNet-L-cpu

FFDNet-S 是一个 600 万参数的目标检测模型,在论文 CommonForms: A Large, Diverse Dataset for Form Field Detection 中使用的数据集上训练。 该模型从三个类别中检测控件:文本框、选择按钮(复选框)和签名字段(Signatures)。

⚠️ 这是模型的 CPU 优化版 ONNX 导出!

结果

模型 文本 选择 签名 AP (↑)
FFDNet-S (1216px) 61.5 71.3 84.2 72.3
FFDNet-L (1216px) 71.4 78.1 93.5 81.0

安装

commonforms 包可以使用 uvpip 安装,您可以根据喜好选择包管理器。 uv 命令:

uv pip install commonforms

pip 命令:

pip install commonforms

安装完成后,您应该能够在几乎任何 PDF 上运行 CLI 命令。 请参阅 commonforms 文档获取最新信息。

命令行工具

最简单的用法是使用默认推荐设置在 CPU 上运行推理:

commonforms <input.pdf> <output.pdf>
输入 输出
输入 PDF 输出 PDF

命令行参数

参数 类型 默认值 描述
input Path 必需 输入 PDF 文件路径
output Path 必需 输出 PDF 文件保存路径
--model str FFDNet-L 模型名称或自定义 .pt 文件路径
--keep-existing-fields flag False 保留 PDF 中现有的表单字段
--use-signature-fields flag False 对检测到的签名使用签名字段而非文本字段
--device str cpu 推理设备(如 cpucuda0
--image-size int 1600 推理图像尺寸
--confidence float 0.3 检测置信度阈值
--fast flag False 如果在 CPU 上运行,可以牺牲准确率换取速度,运行时间约为原来的一半

CommonForms API

除了命令行工具,您还可以使用 Python API:

from commonforms import prepare_form

prepare_form(
    \"path/to/input.pdf\",
    \"path/to/output.pdf\"
)

上述所有参数都是 prepare_form 函数的关键字参数。 例如,如果您想在 1216 分辨率下准备带有签名字段的表单并保留现有字段,可以运行:

from commonforms import prepare_form

prepare_form(
    \"path/to/input.pdf\",
    \"path/to/output.pdf\",
    keep_existing_fields=True,
    use_signature_fields=True,
    image_size=1216
)

参考文献

jbarrow/FFDNet-S-cpu

作者 jbarrow

object-detection commonforms
↓ 0 ♥ 0

创建时间: 2025-10-15 00:30:44+00:00

更新时间: 2025-11-26 02:30:39+00:00

在 Hugging Face 上查看

文件 (3)

.gitattributes
FFDNet-S.onnx ONNX
README.md