Jwalit commited on
Commit
06fc3fd
·
verified ·
1 Parent(s): 4d3fefd

Update model card with V2 results and V1/V2 comparison

Browse files
Files changed (1) hide show
  1. README.md +44 -19
README.md CHANGED
@@ -29,12 +29,22 @@ Binary classifier: detects whether a document image contains moiré artifacts
29
  - `clean` (0): No moiré patterns
30
  - `moire` (1): Moiré patterns detected
31
 
32
- ## V2 Improvements (over V1)
33
- - **Larger model:** DeiT-small (22M params) vs DeiT-tiny (5.5M)
34
- - **More training data:** 8,000 samples vs 6,000
35
- - **6 moiré methods** (added subtle + localized patterns as hard examples)
36
- - **Label smoothing** (0.05) for better calibration
37
- - **Stronger augmentation** (rotation, hue jitter)
 
 
 
 
 
 
 
 
 
 
38
 
39
  ## Training Details
40
 
@@ -43,11 +53,13 @@ Binary classifier: detects whether a document image contains moiré artifacts
43
  | Base model | `facebook/deit-small-patch16-224` |
44
  | Parameters | 22M |
45
  | Training samples | 8,000 (4,000 clean + 4,000 moiré) |
46
- | Test samples | 800 (400 clean + 400 moiré) |
47
  | Epochs | 5 |
48
- | Learning rate | 3e-05 (cosine schedule) |
49
  | Effective batch size | 64 |
50
  | Label smoothing | 0.05 |
 
 
51
 
52
  ### Moiré Generation Methods
53
  1. **Resize aliasing** — downscale+upscale with NEAREST interpolation + pattern overlay
@@ -57,14 +69,25 @@ Binary classifier: detects whether a document image contains moiré artifacts
57
  5. **Subtle moiré** — very low strength single-frequency (hard examples)
58
  6. **Localized moiré** — moiré in elliptical region with gaussian mask
59
 
60
- ## Performance
61
 
62
- | Metric | Eval |
63
- |--------|------|
64
- | Accuracy | 0.9912 |
65
  | F1 Score | 0.9913 |
66
- | Precision | 0.9852 |
67
- | Recall | 0.9975 |
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  ## Usage
70
 
@@ -90,11 +113,13 @@ image = Image.open("document.jpg")
90
  inputs = processor(image, return_tensors="pt")
91
  with torch.no_grad():
92
  logits = model(**inputs).logits
93
- label = model.config.id2label[logits.argmax(-1).item()]
94
- print(label) # 'clean' or 'moire'
 
95
  ```
96
 
97
  ## Limitations
98
- - Trained on synthetic moiré — may not capture all real-world variations
99
- - Optimized for document images; natural scenes may vary
100
- - Input resized to 224×224; very subtle moiré in high-res images may be lost
 
 
29
  - `clean` (0): No moiré patterns
30
  - `moire` (1): Moiré patterns detected
31
 
32
+ ## V1 V2 Comparison
33
+
34
+ | | V1 (DeiT-tiny) | **V2 (DeiT-small)** |
35
+ |---|---|---|
36
+ | **Parameters** | 5.5M | **22M** |
37
+ | **Training samples** | 6,000 | **8,000** |
38
+ | **Moiré methods** | 4 | **6** (+subtle, +localized) |
39
+ | **Label smoothing** | — | **0.05** |
40
+ | **Accuracy** | 99.5% | **99.1%** |
41
+ | **F1 Score** | 0.995 | **0.991** |
42
+ | **Precision** | 99.3% | **98.5%** |
43
+ | **Recall** | 99.7% | **99.8%** |
44
+
45
+ > **Note:** V2 was evaluated on harder examples including subtle single-frequency moiré and localized
46
+ > moiré patterns that V1 never trained on. V2 achieves near-perfect recall (99.75%) — it catches
47
+ > virtually all moiré patterns including very subtle ones, at the cost of slightly lower precision.
48
 
49
  ## Training Details
50
 
 
53
  | Base model | `facebook/deit-small-patch16-224` |
54
  | Parameters | 22M |
55
  | Training samples | 8,000 (4,000 clean + 4,000 moiré) |
56
+ | Eval samples | 800 (400 clean + 400 moiré) |
57
  | Epochs | 5 |
58
+ | Learning rate | 3e-5 (cosine schedule) |
59
  | Effective batch size | 64 |
60
  | Label smoothing | 0.05 |
61
+ | Warmup steps | 60 |
62
+ | Best checkpoint | Epoch 2 (by F1) |
63
 
64
  ### Moiré Generation Methods
65
  1. **Resize aliasing** — downscale+upscale with NEAREST interpolation + pattern overlay
 
69
  5. **Subtle moiré** — very low strength single-frequency (hard examples)
70
  6. **Localized moiré** — moiré in elliptical region with gaussian mask
71
 
72
+ ## Performance (Best Checkpoint)
73
 
74
+ | Metric | Value |
75
+ |--------|-------|
76
+ | Accuracy | 99.12% |
77
  | F1 Score | 0.9913 |
78
+ | Precision | 98.52% |
79
+ | Recall | 99.75% |
80
+ | Eval Loss | 0.170 |
81
+
82
+ ### Training Progression
83
+
84
+ | Epoch | Eval Loss | Accuracy | F1 | Precision | Recall |
85
+ |-------|-----------|----------|-----|-----------|--------|
86
+ | 1 | 0.173 | 99.0% | 0.990 | 99.3% | 98.8% |
87
+ | 2 | 0.177 | 99.1% | **0.991** | 99.0% | 99.3% |
88
+ | 3 | 0.154 | 99.1% | 0.991 | 99.3% | 99.0% |
89
+ | 4 | 0.170 | 99.1% | **0.991** | 98.5% | **99.8%** |
90
+ | 5 | 0.168 | 99.0% | 0.990 | 98.3% | **99.8%** |
91
 
92
  ## Usage
93
 
 
113
  inputs = processor(image, return_tensors="pt")
114
  with torch.no_grad():
115
  logits = model(**inputs).logits
116
+ predicted = logits.argmax(-1).item()
117
+
118
+ print(model.config.id2label[predicted]) # 'clean' or 'moire'
119
  ```
120
 
121
  ## Limitations
122
+ - Trained on synthetic moiré patterns — may not capture all real-world moiré variations
123
+ - Optimized for document images; performance on natural scene images may vary
124
+ - Input images resized to 224×224; very subtle moiré in high-resolution images may be lost
125
+ - Higher recall than precision — may occasionally flag clean images as moiré (false positive rate ~1.5%)