Eroux commited on
Commit
51a8f6f
Β·
verified Β·
1 Parent(s): a049d04

Tune text-area threshold to 0.55 (native per-class sweep)

Browse files
Files changed (1) hide show
  1. README.md +20 -16
README.md CHANGED
@@ -78,20 +78,24 @@ combined losslessly downstream).
78
 
79
  ## Recommended usage β€” per-class confidence thresholds
80
 
81
- The detector is deliberately recall-happy on the small marginal header/footer
82
- boxes, so **the best operating point differs by class**. Using the Ultralytics
83
- default `conf=0.25` for everything leaves header/footer precision at only β‰ˆ0.83.
84
- Raising *just* the header/footer threshold to **β‰ˆ0.60** lifts their precision to
85
- β‰ˆ0.95 for a β‰ˆ0.02 recall cost.
86
 
87
- | class | recommended conf |
88
- | --- | --- |
89
- | header (0) | **0.60** |
90
- | text-area (1) | 0.25 |
91
- | footnote (2) | 0.25 |
92
- | footer (3) | **0.60** |
 
 
 
 
 
93
 
94
- If you need a single global threshold, **0.45** is the best compromise.
95
 
96
  ### Inference
97
 
@@ -101,7 +105,7 @@ from ultralytics import RTDETR
101
  model = RTDETR("tibetan_book_layout.pt")
102
 
103
  # predict once at the lowest floor, then filter per class
104
- CLASS_CONF = {0: 0.60, 1: 0.25, 2: 0.25, 3: 0.60} # header, text-area, footnote, footer
105
  results = model.predict("page.jpg", imgsz=1024, conf=min(CLASS_CONF.values()))
106
 
107
  for r in results:
@@ -144,9 +148,9 @@ The **mAP** columns are threshold-independent β€” they integrate over the full
144
  precision/recall curve (every confidence), so they do not depend on any operating
145
  threshold. The **P / R / F1** columns are reported at each class's own
146
  **maximum-F1 confidence** (the standard Ultralytics `val` operating point), *not*
147
- at a fixed 0.25 or 0.60. The per-class serving thresholds recommended above
148
- (header/footer β‰ˆ 0.60, text-area / footnote β‰ˆ 0.25) are the practical settings
149
- for `infer.py`; they land close to these max-F1 points.
150
 
151
  ### Canonical 3-class metrics
152
 
 
78
 
79
  ## Recommended usage β€” per-class confidence thresholds
80
 
81
+ The detector is deliberately recall-happy, so **the best operating point differs
82
+ by class**. Using the Ultralytics default `conf=0.25` everywhere leaves
83
+ header/footer precision at only β‰ˆ0.83 and text-area at β‰ˆ0.955. Two cheap fixes,
84
+ both measured with a native per-class confidence sweep on the test set:
 
85
 
86
+ - Raise **header/footer to β‰ˆ0.60** β†’ precision β‰ˆ0.83 β†’ β‰ˆ0.95 (β‰ˆ0.02 recall cost).
87
+ - Raise **text-area to β‰ˆ0.55** β†’ precision β‰ˆ0.955 β†’ β‰ˆ0.98 (β‰ˆ0.002 recall cost).
88
+ - Leave **footnote at β‰ˆ0.25**, where recall is β‰ˆ1.0 (its few false positives are
89
+ high-confidence and can't be thresholded away without losing real footnotes).
90
+
91
+ | class | recommended conf | P β†’ P | R |
92
+ | --- | --- | --- | --- |
93
+ | header (0) | **0.60** | 0.83 β†’ 0.96 | 0.95 |
94
+ | text-area (1) | **0.55** | 0.955 β†’ 0.98 | 0.995 |
95
+ | footnote (2) | 0.25 | 0.918 | 1.00 |
96
+ | footer (3) | **0.60** | β€” β†’ 0.94 | 0.95 |
97
 
98
+ If you need a single global threshold, **0.50** is the best compromise.
99
 
100
  ### Inference
101
 
 
105
  model = RTDETR("tibetan_book_layout.pt")
106
 
107
  # predict once at the lowest floor, then filter per class
108
+ CLASS_CONF = {0: 0.60, 1: 0.55, 2: 0.25, 3: 0.60} # header, text-area, footnote, footer
109
  results = model.predict("page.jpg", imgsz=1024, conf=min(CLASS_CONF.values()))
110
 
111
  for r in results:
 
148
  precision/recall curve (every confidence), so they do not depend on any operating
149
  threshold. The **P / R / F1** columns are reported at each class's own
150
  **maximum-F1 confidence** (the standard Ultralytics `val` operating point), *not*
151
+ at a fixed threshold. The per-class serving thresholds recommended above
152
+ (header/footer β‰ˆ 0.60, text-area β‰ˆ 0.55, footnote β‰ˆ 0.25) are the practical
153
+ settings for `infer.py`; they land close to these max-F1 points.
154
 
155
  ### Canonical 3-class metrics
156