PSynx commited on
Commit
dc4dc63
·
verified ·
1 Parent(s): 34873a8

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +81 -0
README.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ library_name: ultralytics
6
+ tags:
7
+ - yolo11
8
+ - object-detection
9
+ - document-ai
10
+ - form-understanding
11
+ - vision
12
+ pipeline_tag: object-detection
13
+ ---
14
+
15
+ # YOLO11m Document Widget Detector
16
+
17
+ This is a fine-tuned YOLO11m model for detecting interactive form widgets (text inputs, checkboxes/radio buttons, and signatures) in document images and PDFs.
18
+
19
+ It was trained on the [CommonForms](https://huggingface.co/datasets/jbarrow/CommonForms) dataset (100,000 document images) and achieves high accuracy across diverse document layouts.
20
+
21
+ ## Model Details
22
+ - **Architecture:** YOLO11m
23
+ - **Task:** Object Detection (Document Widgets)
24
+ - **Classes:**
25
+ - `0`: `text_input`
26
+ - `1`: `choice_button` (checkboxes & radio buttons)
27
+ - `2`: `signature`
28
+ - **Input Size:** 1024x1024
29
+
30
+ ## Performance (mAP@50)
31
+ - **text_input:** 0.814
32
+ - **choice_button:** 0.709
33
+ - **signature:** 0.838
34
+ - **Overall mAP@50:** 0.787
35
+
36
+ ## Usage
37
+
38
+ ### Using the Python Package
39
+
40
+ You can install the official inference package to automatically download this model and process PDFs or images.
41
+
42
+ ```bash
43
+ pip install widget-detector
44
+ ```
45
+
46
+ ```python
47
+ from widget_detector import WidgetDetector
48
+
49
+ # Initialize without a path to auto-download from Hugging Face
50
+ detector = WidgetDetector()
51
+
52
+ # Run inference on a PDF (auto-renders pages to images)
53
+ result = detector.detect_path("sample_form.pdf")
54
+
55
+ # Print results
56
+ for page in result.pages:
57
+ print(f"Page {page.page}: Found {len(page.widgets)} widgets")
58
+ for w in page.widgets:
59
+ print(f" - {w.class_name} ({w.confidence:.2f}) at {w.bbox.x1:.1f}, {w.bbox.y1:.1f}")
60
+
61
+ # Save to JSON
62
+ result.save("output.json")
63
+ ```
64
+
65
+ ### Using Ultralytics Directly
66
+
67
+ If you prefer to use the raw Ultralytics library:
68
+
69
+ ```python
70
+ from ultralytics import YOLO
71
+ from huggingface_hub import hf_hub_download
72
+
73
+ # Download the model weights
74
+ model_path = hf_hub_download(repo_id="PSynx/widget-detector-yolo", filename="best.pt")
75
+
76
+ # Load the model
77
+ model = YOLO(model_path)
78
+
79
+ # Run inference
80
+ results = model("document_image.png", imgsz=1024, conf=0.25)
81
+ ```