File size: 3,478 Bytes
cb79f96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
pipeline_tag: object-detection
tags:
- form-field-detection
- documents
- commonforms
library_name: commonforms
datasets:
  - jbarrow/CommonForms
---

๐Ÿช„ Automatically convert a PDF into a fillable form.

[๐Ÿ’ป Hosted Models (detect.semanticdocs.org)](https://detect.semanticdocs.org) | [๐Ÿ“„ CommonForms Paper](https://arxiv.org/abs/2509.16506) | [๐Ÿค— Dataset](https://huggingface.co/datasets/jbarrow/CommonForms) | [๐Ÿฆพ Models](https://github.com/jbarrow/commonforms/tree/main/commonforms/models)

![Pipeline](https://raw.githubusercontent.com/jbarrow/commonforms/main/assets/pipeline.png)

# FFDNet-S

FFDNet-S is the 6 million parameter object detector trained on the dataset from the paper [CommonForms: A Large, Diverse Dataset for Form Field Detection](https://arxiv.org/abs/2509.16506).
The model detects widgets from among three classes: TextBoxes, ChoiceButtons (checkboxes), and Signature fields.

## Results

| Model | Text | Choice | Signature | AP (โ†‘) |
|-------|------|--------|-----------|--------|
| FFDNet-S (1216px) | 61.5 | 71.3 | 84.2 | 72.3 |
| FFDNet-L (1216px) | 71.4 | 78.1 | 93.5 | 81.0 |


## Installation

The `commonforms` package can be installed with either `uv` or `pip`, feel free to choose your package manager flavor.
The `uv` command:

```sh
uv pip install commonforms
```

The `pip` command:

```
pip install commonforms
```

Once it's installed, you should be able to run the CLI command on ~any PDF.
Refer to [the `commonforms` documentation](https://github.com/jbarrow/commonforms) for the latest information.

## CLI

The simplest usage will run inference on your CPU using the default suggested settings:

```
commonforms <input.pdf> <output.pdf>
```

| Input | Output |
|-------|--------|
| ![Input PDF](https://raw.githubusercontent.com/jbarrow/commonforms/main/assets/input.png) | ![Output PDF](https://raw.githubusercontent.com/jbarrow/commonforms/main/assets/output.png) |

### Command Line Arguments

| Argument | Type | Default | Description |
|----------|------|---------|-------------|
| `input` | Path | Required | Path to the input PDF file |
| `output` | Path | Required | Path to save the output PDF file |
| `--model` | str | `FFDNet-L` | Model name (FFDNet-L/FFDNet-S) or path to custom .pt file |
| `--keep-existing-fields` | flag | `False` | Keep existing form fields in the PDF |
| `--use-signature-fields` | flag | `False` | Use signature fields instead of text fields for detected signatures |
| `--device` | str | `cpu` | Device for inference (e.g., `cpu`, `cuda`, `0`) |
| `--image-size` | int | `1600` | Image size for inference |
| `--confidence` | float | `0.3` | Confidence threshold for detection |
| `--fast` | flag | `False` | If running on a CPU, you can trade off accuracy for speed and run in about half the time |

## CommonForms API

In addition to the CLI, you can use

```py
from commonforms import prepare_form

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

All of the above arguments are keyword arguments to the `prepare_form` function.
E.g. if you want to prepare a with signature fields and keep existing fields at 1216 resolution, you would run:

```
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
)
```

## References

* [CommonForms: A Large, Diverse Dataset for Form Field Detection](https://arxiv.org/abs/2509.16506)