0xgr3y commited on
Commit
f799753
Β·
verified Β·
1 Parent(s): a42f640

update: model card README with latest metrics and evaluation results

Browse files
Files changed (1) hide show
  1. README.md +76 -67
README.md CHANGED
@@ -30,25 +30,25 @@ model-index:
30
  split: test
31
  metrics:
32
  - type: accuracy
33
- value: 0.9777
34
  name: Test Accuracy
35
  - type: accuracy
36
- value: 0.9836
37
  name: Validation Accuracy (SWA)
38
  - type: accuracy
39
- value: 0.9799
40
  name: TTA Accuracy
41
  - type: f1
42
- value: 0.9777
43
  name: Macro F1
44
  - type: precision
45
- value: 0.9777
46
  name: Macro Precision
47
  - type: recall
48
- value: 0.9777
49
  name: Macro Recall
50
  - type: roc_auc
51
- value: 0.9985
52
  name: Macro ROC-AUC (OvR)
53
  ---
54
 
@@ -63,7 +63,7 @@ Fine-Grained Image Classification (FGIC) of world architectural buildings using
63
  <table>
64
  <tr><td><strong>Architecture</strong></td><td>EfficientNetV2-S + GeM Pooling + Focal Loss + SWA</td></tr>
65
  <tr><td><strong>Task</strong></td><td>Fine-Grained Image Classification (FGIC)</td></tr>
66
- <tr><td><strong>Test Accuracy</strong></td><td>97.77%</td></tr>
67
  <tr><td><strong>Classes</strong></td><td>8 (barn, bridge, castle, mosque, skyscraper, stadium, temple, windmill)</td></tr>
68
  <tr><td><strong>Input Size</strong></td><td>320 Γ— 320 pixels</td></tr>
69
  <tr><td><strong>Parameters</strong></td><td>23,350,633</td></tr>
@@ -83,10 +83,10 @@ A fine-grained image classification model for world architectural buildings. Bui
83
  - **Mixup + CutMix** (Zhang et al., ICLR 2018. Yun et al., ICCV 2019) β€” alternating per-batch (50/50): Mixup (alpha=0.2, linear interpolation) and CutMix (alpha=1.0, spatial patch). Applied only in Phase 1 training to regularize head learning
84
  - **Selective Unfreeze** (Yosinski et al., 2014) β€” Phase 2 unfreezes block6+top_conv layers (180/513 EfficientNetV2-S layers) while keeping BatchNormalization frozen to preserve pretrained statistics
85
  - **SWA with BN re-estimation** (Izmailov et al., UAI 2018) β€” 10-epoch post-training weight averaging with constant LR 1e-4, followed by 100-step batch normalization statistics re-estimation (3,200 images)
86
- - **Test-Time Augmentation** β€” 6 variations averaged at inference: original, horizontal flip, center crop 85%, center crop 70%, corner crop top-left 80%, corner crop bottom-right 80%. Yields +0.22% accuracy improvement (97.77% β†’ 97.99%)
87
  - **Grad-CAM** (Selvaraju et al., ICCV 2017) β€” gradient-weighted class activation mapping for explainability, targeting *top_conv* (last Conv2D layer of EfficientNetV2-S)
88
  - **ECE Calibration** (Guo et al., ICML 2017) β€” Expected Calibration Error with 15-bin reliability diagram to assess prediction confidence reliability
89
- - **Temperature Scaling** (Guo et al., ICML 2017) β€” post-hoc calibration via scalar temperature parameter T optimized on validation set (NLL minimization). T=0.54 reduces ECE from 12.04% (underconfident due to Label Smoothing) to 0.53% β€” applied at inference via (softmax(log(probs) / T)) trick
90
 
91
  ## Architecture
92
 
@@ -121,10 +121,11 @@ Output (8 classes)
121
  | BatchNormalization | (None, 256) | 1,024 |
122
  | Dropout 0.4 | (None, 256) | 0 |
123
  | Dense 8 Softmax | (None, 8) | 2,056 |
124
- | **Total** | | **23,350,633** |
125
  | Trainable (Phase 1) | | **3,018,249** (11.51 MB) |
126
  | Trainable (Phase 2) | | **17,810,225** (67.94 MB) |
127
  | Non-trainable (Phase 1) | | **20,332,384** (77.56 MB) |
 
128
 
129
  ## Performance
130
 
@@ -132,32 +133,33 @@ Output (8 classes)
132
 
133
  | Metric | Value |
134
  |--------|-------|
135
- | Test Accuracy | 97.77% |
136
- | Validation Accuracy (SWA) | 98.36% |
137
- | Test-Time Augmentation | 97.99% |
138
- | Test Loss | 0.4262 |
139
- | Overfitting Gap (Train βˆ’ Test) | 2.11% |
140
- | Macro Avg Precision | 0.9777 |
 
141
  | Macro Avg Recall | 0.9777 |
142
  | Macro Avg F1-Score | 0.9777 |
143
- | Top-2 Accuracy | 99.26% |
144
- | Top-3 Accuracy | 99.70% |
145
- | Macro ROC-AUC (OvR) | 0.9985 |
146
- | ECE (15 bins) | 0.1204 (pre-T-scaling. post-T-scaling: 0.0053, T=0.54) |
147
 
148
  ### Per-Class Results
149
 
150
  | Class | Precision | Recall | F1-Score | AUC (OvR) | Support |
151
  |-------|-----------|--------|----------|-----------|---------|
152
- | barn | 0.9760 | 0.9702 | 0.9731 | 0.9950 | 168 |
153
- | bridge | 0.9591 | 0.9762 | 0.9676 | 0.9983 | 168 |
154
- | castle | 0.9763 | 0.9821 | 0.9792 | 0.9996 | 168 |
155
- | mosque | 0.9763 | 0.9821 | 0.9792 | 0.9987 | 168 |
156
- | skyscraper | 0.9940 | 0.9940 | 0.9940 | 0.9999 | 168 |
157
- | stadium | 0.9820 | 0.9762 | 0.9791 | 0.9999 | 168 |
158
- | temple | 0.9816 | 0.9524 | 0.9668 | 0.9976 | 168 |
159
- | windmill | 0.9765 | 0.9881 | 0.9822 | 0.9987 | 168 |
160
- | **Macro Avg** | **0.9777** | **0.9777** | **0.9777** | **0.9985** | **1,344** |
161
 
162
  ### Model Selection
163
 
@@ -165,30 +167,38 @@ Four candidate models were evaluated on the validation set:
165
 
166
  | Checkpoint | Val Accuracy | Val Loss | Description |
167
  |------------|-------------|----------|-------------|
168
- | `head_training.keras` | 92.34% | 1.0109 | Phase 1 checkpoint (backbone frozen) |
169
- | `fine_tuning.keras` | 96.28% | 0.5655 | Phase 2 checkpoint (block6+top_conv unfrozen) |
170
- | `fine_tuning_ema.keras` | 93.53% | 0.6007 | Phase 2 EMA (per-step Polyak averaging) |
171
- | **`fine_tuning_swa.keras`** | **98.36%** | **0.4109** | **SWA averaged weights ← SELECTED** |
172
 
173
  ### Training Progression
174
 
175
  | Phase | Epoch | Train Acc | Val Accuracy | Val Loss |
176
  |-------|-------|-----------|-------------|----------|
177
- | Phase 1 (Head Training) | 1 | 56.96% | 92.19% | 1.0079 |
178
- | Phase 2 (Selective Fine-Tuning) | 1 | 84.96% | 96.21% | 0.5656 |
179
- | SWA | 1 | 90.83% | 95.76% | 0.5831 |
180
- | SWA | 2 | 94.07% | 97.62% | 0.5116 |
181
- | SWA | 3 | 95.36% | 97.69% | 0.4748 |
182
- | SWA | 4 | 96.56% | 96.95% | 0.4390 |
183
- | SWA | 5 | 97.18% | 97.47% | 0.4490 |
184
- | SWA | 6 | 97.76% | 97.84% | 0.4416 |
185
- | SWA | 7 | 97.91% | 98.14% | 0.4055 |
186
- | SWA | 8 | 98.19% | 97.32% | 0.4359 |
187
- | SWA | 9 | 98.14% | 97.02% | 0.4519 |
188
- | SWA | 10 | 98.59% | 97.54% | 0.4226 |
189
- | **SWA + BN (final)** | β€” | β€” | **98.36%** | **0.4109** |
190
-
191
- > Phase 1 and Phase 2 each stopped after 1 epoch via `myCallback` (custom early stopping at target accuracy: 85% Phase 1, 92% Phase 2). SWA ran 10 epochs with constant LR 1e-4, followed by BN re-estimation (100 steps, 3,200 images). Values shown are training-time metrics from progress bar. checkpoint evaluation values may differ slightly (see Model Selection table above).
 
 
 
 
 
 
 
 
192
 
193
  ![Training Curves](results/training_curves.png)
194
 
@@ -210,12 +220,12 @@ Two-phase progressive training with SWA post-processing:
210
 
211
  | Phase | Description | Backbone | Optimizer | LR | Max Epochs | Actual Epochs | CutMix+Mixup | FocalLoss LS |
212
  |-------|-------------|----------|-----------|-----|-----------|---------------|---------------|-------------|
213
- | **Phase 1** β€” Feature Extraction | Train custom head only | Frozen (all) | AdamW (wd=2e-5) | 0.001 + CosineDecay + Warmup 3ep | 25 | 1 | Yes (50/50 alternation) | 0.1 |
214
- | **Phase 2** β€” Selective Fine-Tuning | Load head_training β†’ fine-tune | block6 + top_conv unfrozen (BN frozen) | DiscriminativeAdamW (block6=0.1Γ—) | 3e-4 + CosineDecay + Warmup 5ep | 50 | 1 + 10 SWA | No | 0.05 |
215
 
216
- > ΒΉ Phase 1 stops when `val_accuracy β‰₯ 85%` threshold (myCallback).
217
 
218
- > Β² Phase 2 stops when `val_accuracy β‰₯ 92%` threshold (myCallback), followed by 10 SWA epochs (constant LR 1e-4).
219
 
220
  ### Hyperparameters
221
 
@@ -229,8 +239,7 @@ Two-phase progressive training with SWA post-processing:
229
  | LR Multiplier (top_conv+head) | β€” | 1.0Γ— |
230
  | Loss | FocalLoss (gamma=2.0, LS=0.1) | FocalLoss (gamma=2.0, LS=0.05) |
231
  | Batch Size | 32 | 32 |
232
- | Early Stopping Patience | 7 | 12 |
233
- | myCallback Threshold | val_acc β‰₯ 0.85 | val_acc β‰₯ 0.92 |
234
  | EMA Decay (per-step) | 0.999 | 0.999 |
235
  | SWA Epochs | β€” | 10 (post-training) |
236
  | SWA LR | β€” | 1Γ—10⁻⁴ (constant) |
@@ -258,7 +267,7 @@ Two-phase progressive training with SWA post-processing:
258
  | Random Erasing | p=0.5, area [0.02–0.15], aspect [0.3–3.3], applied pre-normalization | Zhong et al., AAAI 2020 |
259
  | Test-Time Augmentation | 6 augmentation variants, averaged | Shanmugam et al., ICML 2020 |
260
  | WarmupCosineDecay | Linear warmup + cosine annealing | Loshchilov & Hutter, ICLR 2017 (SGDR) |
261
- | Early Stopping | Patience 7 (Phase 1) / 12 (Phase 2) | Prechelt, Neural Networks 1998 |
262
 
263
  ### Dataset
264
 
@@ -281,12 +290,12 @@ See the dataset curation page for [World Architectural Buildings Dataset for Mul
281
 
282
  | Category | Files |
283
  |----------|-------|
284
- | **Model (best)** | `fine_tuning_swa.keras` (227 MB) Β· `.weights.h5` (158 MB) Β· `.safetensors` (157 MB) |
285
- | **Code** | `build_model.py` (21 KB) β€” architecture + CLI inference |
286
  | **Config** | `config.json` Β· `label_mapping.json` Β· `preprocessor_config.json` |
287
  | **Evaluation** | `calibration_data.json` Β· `model_benchmark.json` Β· `confusion_pairs.json` Β· `class_confidence_stats.json` Β· `temperature_config.json` |
288
- | **Deployment** | `saved_model/` (183 MB) Β· `tflite/` (88 MB) Β· `tfjs_model/` (90 MB, 23 shards) |
289
- | **Results** | `results/` β€” 12 PNG (augmentation, reliability-diagram, training curves, confusion matrix, ROC, t-SNE, Grad-CAM, etc.) |
290
  | **Archive** | `models_keras/` β€” 3 checkpoints (head_training, fine_tuning, fine_tuning_ema) |
291
 
292
  ## Usage
@@ -452,13 +461,13 @@ Keras vs TFLite consistency was verified on 8 random test samples (1 per class):
452
 
453
  | Metric | Result |
454
  |--------|--------|
455
- | Keras correct | 7/8 (88%) |
456
- | TFLite correct | 7/8 (88%) |
457
  | Keras vs TFLite match | **8/8 (100%)** β€” identical predictions |
458
- | Keras inference speed | 358.0 ms |
459
- | TFLite inference speed | 170.0 ms |
460
 
461
- > The 1 misclassification (castle→barn, 65% confidence) is consistent with the 97.77% test accuracy. The 8/8 match confirms TFLite conversion preserves model behavior exactly.
462
 
463
  ![TFLite Inference](results/inference_tflite.png)
464
 
@@ -484,13 +493,13 @@ With model is provided in multiple formats to suit different deployment scenario
484
 
485
  | Format | File | Size | Protect AI | Inference Speed | Best For |
486
  |--------|------|------|------------|-----------------|----------|
487
- | **TF-Lite** βœ“ | `tflite/model.tflite` | ~88 MB | βœ“ Safe | **170.0 ms** (fastest) | Mobile, edge, embedded, HF Space |
488
  | **SavedModel** βœ“ | `saved_model/` | ~183 MB | βœ“ Safe | β€” | TensorFlow Serving, cloud backend |
489
  | **TFJS** βœ“ | `tfjs_model/` | ~90 MB | βœ“ Safe | β€” | Browser, Node.js (no backend) |
490
  | **Weights H5** βœ“ | `fine_tuning_swa.weights.h5` | ~158 MB | βœ“ Safe | β€” | Programmatic load via `build_model.py` |
491
  | **safetensors** βœ“ | `fine_tuning_swa.safetensors` | ~157 MB | βœ“ Safe | β€” | HF standard, cross-framework |
492
  | **Build Script** βœ“ | `build_model.py` | ~21 KB | βœ“ Safe | β€” | Architecture reconstruction + `load_weights()` |
493
- | **Keras** β„Ή | `fine_tuning_swa.keras` | ~227 MB | β„Ή Flagged | 358.0 ms | Developer reference, fine-tuning |
494
 
495
  ### Load Examples
496
 
 
30
  split: test
31
  metrics:
32
  - type: accuracy
33
+ value: 0.9792
34
  name: Test Accuracy
35
  - type: accuracy
36
+ value: 0.9851
37
  name: Validation Accuracy (SWA)
38
  - type: accuracy
39
+ value: 0.9814
40
  name: TTA Accuracy
41
  - type: f1
42
+ value: 0.9792
43
  name: Macro F1
44
  - type: precision
45
+ value: 0.9794
46
  name: Macro Precision
47
  - type: recall
48
+ value: 0.9792
49
  name: Macro Recall
50
  - type: roc_auc
51
+ value: 0.9975
52
  name: Macro ROC-AUC (OvR)
53
  ---
54
 
 
63
  <table>
64
  <tr><td><strong>Architecture</strong></td><td>EfficientNetV2-S + GeM Pooling + Focal Loss + SWA</td></tr>
65
  <tr><td><strong>Task</strong></td><td>Fine-Grained Image Classification (FGIC)</td></tr>
66
+ <tr><td><strong>Test Accuracy</strong></td><td>97.92%</td></tr>
67
  <tr><td><strong>Classes</strong></td><td>8 (barn, bridge, castle, mosque, skyscraper, stadium, temple, windmill)</td></tr>
68
  <tr><td><strong>Input Size</strong></td><td>320 Γ— 320 pixels</td></tr>
69
  <tr><td><strong>Parameters</strong></td><td>23,350,633</td></tr>
 
83
  - **Mixup + CutMix** (Zhang et al., ICLR 2018. Yun et al., ICCV 2019) β€” alternating per-batch (50/50): Mixup (alpha=0.2, linear interpolation) and CutMix (alpha=1.0, spatial patch). Applied only in Phase 1 training to regularize head learning
84
  - **Selective Unfreeze** (Yosinski et al., 2014) β€” Phase 2 unfreezes block6+top_conv layers (180/513 EfficientNetV2-S layers) while keeping BatchNormalization frozen to preserve pretrained statistics
85
  - **SWA with BN re-estimation** (Izmailov et al., UAI 2018) β€” 10-epoch post-training weight averaging with constant LR 1e-4, followed by 100-step batch normalization statistics re-estimation (3,200 images)
86
+ - **Test-Time Augmentation** β€” 6 variations averaged at inference: original, horizontal flip, center crop 85%, corner crop 70%, corner crop top-left 80%, corner crop bottom-right 80%. Yields +0.22% accuracy improvement (97.92% β†’ 98.14%)
87
  - **Grad-CAM** (Selvaraju et al., ICCV 2017) β€” gradient-weighted class activation mapping for explainability, targeting *top_conv* (last Conv2D layer of EfficientNetV2-S)
88
  - **ECE Calibration** (Guo et al., ICML 2017) β€” Expected Calibration Error with 15-bin reliability diagram to assess prediction confidence reliability
89
+ - **Temperature Scaling** (Guo et al., ICML 2017) β€” post-hoc calibration via scalar temperature parameter T optimized on validation set (NLL minimization). T=0.4645 reduces ECE from 18.13% (underconfident due to Label Smoothing) to 0.95% β€” applied at inference via (softmax(log(probs) / T)) trick
90
 
91
  ## Architecture
92
 
 
121
  | BatchNormalization | (None, 256) | 1,024 |
122
  | Dropout 0.4 | (None, 256) | 0 |
123
  | Dense 8 Softmax | (None, 8) | 2,056 |
124
+ | **Total** | | **23,350,633** (89.08 MB) |
125
  | Trainable (Phase 1) | | **3,018,249** (11.51 MB) |
126
  | Trainable (Phase 2) | | **17,810,225** (67.94 MB) |
127
  | Non-trainable (Phase 1) | | **20,332,384** (77.56 MB) |
128
+ | Non-trainable (Phase 2) | | **5,540,408** (21.13 MB) |
129
 
130
  ## Performance
131
 
 
133
 
134
  | Metric | Value |
135
  |--------|-------|
136
+ | Test Accuracy | 97.92% |
137
+ | Validation Accuracy (SWA) | 98.51% |
138
+ | Test-Time Augmentation | TBD |
139
+ | Test Loss | 0.3928 |
140
+ | Overfitting Gap (Train βˆ’ Test) | 2.06% |
141
+ | Train Accuracy | 99.97% |
142
+ | Macro Avg Precision | 0.9794 |
143
  | Macro Avg Recall | 0.9777 |
144
  | Macro Avg F1-Score | 0.9777 |
145
+ | Top-2 Accuracy | 99.18% |
146
+ | Top-3 Accuracy | 99.55% |
147
+ | Macro ROC-AUC (OvR) | 0.9975 |
148
+ | ECE (15 bins) | 0.1813 (pre-T-scaling. post-T-scaling: 0.0095, T=0.4645, improvement 94.7%) |
149
 
150
  ### Per-Class Results
151
 
152
  | Class | Precision | Recall | F1-Score | AUC (OvR) | Support |
153
  |-------|-----------|--------|----------|-----------|---------|
154
+ | barn | 0.9760 | 0.9702 | 0.9731 | 0.9955 | 168 |
155
+ | bridge | 0.9706 | 0.9821 | 0.9763 | 0.9977 | 168 |
156
+ | castle | 0.9762 | 0.9762 | 0.9762 | 0.9998 | 168 |
157
+ | mosque | 0.9880 | 0.9821 | 0.9851 | 0.9990 | 168 |
158
+ | skyscraper | 0.9766 | 0.9940 | 0.9853 | 0.9999 | 168 |
159
+ | stadium | 0.9880 | 0.9762 | 0.9820 | 0.9954 | 168 |
160
+ | temple | 1.0000 | 0.9643 | 0.9818 | 0.9944 | 168 |
161
+ | windmill | 0.9595 | 0.9881 | 0.9736 | 0.9979 | 168 |
162
+ | **Macro Avg** | **0.9794** | **0.9792** | **0.9792** | **0.9975** | **1,344** |
163
 
164
  ### Model Selection
165
 
 
167
 
168
  | Checkpoint | Val Accuracy | Val Loss | Description |
169
  |------------|-------------|----------|-------------|
170
+ | `head_training.keras` | 97.47% | 0.6859 | Phase 1 checkpoint (backbone frozen, 25 epoch) |
171
+ | `fine_tuning.keras` | 97.77% | 0.3988 | Phase 2 checkpoint (block6+top_conv unfrozen, 7 epoch) |
172
+ | `fine_tuning_ema.keras` | 97.84% | 0.3732 | Phase 2 EMA (per-step Polyak averaging) |
173
+ | **`fine_tuning_swa.keras`** | **98.51%** | **0.3638** | **SWA averaged weights ← SELECTED** |
174
 
175
  ### Training Progression
176
 
177
  | Phase | Epoch | Train Acc | Val Accuracy | Val Loss |
178
  |-------|-------|-----------|-------------|----------|
179
+ | Phase 1 (Head Training) | 1 | 56.93% | 91.52% | 1.1027 |
180
+ | Phase 1 (Head Training) | 8 | 82.57% | 96.35% | 0.7163 |
181
+ | Phase 1 (Head Training) | 16 | 83.73% | 97.32% | 0.6988 |
182
+ | Phase 1 (Head Training) | **23 (best)** | **84.87%** | **97.54%** | **0.6861** |
183
+ | Phase 2 (Selective Fine-Tuning) | 1 | 96.13% | 97.40% | 0.4109 |
184
+ | Phase 2 (Selective Fine-Tuning) | **2 (best)** | **96.51%** | **97.77%** | **0.3991** |
185
+ | Phase 2 (Selective Fine-Tuning) | 3 | 96.34% | 97.10% | 0.4041 |
186
+ | Phase 2 (Selective Fine-Tuning) | 4 | 96.11% | 96.35% | 0.4436 |
187
+ | Phase 2 (Selective Fine-Tuning) | 5 | 96.64% | 95.76% | 0.4690 |
188
+ | Phase 2 (Selective Fine-Tuning) | 7 (stop) | 97.22% | 96.80% | 0.4267 |
189
+ | SWA | 1 | 97.07% | 97.47% | 0.3938 |
190
+ | SWA | 2 | 97.87% | 97.25% | 0.3927 |
191
+ | SWA | 3 | 98.04% | 97.47% | 0.4064 |
192
+ | SWA | 4 | 98.74% | 97.84% | 0.3956 |
193
+ | SWA | 5 | 98.75% | 97.84% | 0.3938 |
194
+ | SWA | 6 | 99.00% | 97.32% | 0.4073 |
195
+ | SWA | 7 | 98.62% | 97.69% | 0.3847 |
196
+ | SWA | 8 | 99.00% | 97.17% | 0.3948 |
197
+ | SWA | 9 | 99.14% | 97.54% | 0.3981 |
198
+ | SWA | 10 | 98.91% | 97.10% | 0.4218 |
199
+ | **SWA + BN (final)** | β€” | β€” | **98.51%** | **0.3638** |
200
+
201
+ > Phase 1 ran 25 epochs (maximal), best epoch = 23 with `val_accuracy` 97.54%. `EarlyStopping` with `patience=5` was not triggered. Phase 2 ran 7 epochs, best epoch = 2 (`val_accuracy` 97.77%), `EarlyStopping` with `patience=3` triggered. SWA ran 10 epochs with constant LR 1e-4, followed by BN re-estimation (100 steps, 3,200 images).
202
 
203
  ![Training Curves](results/training_curves.png)
204
 
 
220
 
221
  | Phase | Description | Backbone | Optimizer | LR | Max Epochs | Actual Epochs | CutMix+Mixup | FocalLoss LS |
222
  |-------|-------------|----------|-----------|-----|-----------|---------------|---------------|-------------|
223
+ | **Phase 1** β€” Feature Extraction | Train custom head only | Frozen (all) | AdamW (wd=2e-5) | 0.001 + CosineDecay + Warmup 3ep | 25 | 25 (best=23) | Yes (50/50 alternation) | 0.1 |
224
+ | **Phase 2** β€” Selective Fine-Tuning | Load head_training β†’ fine-tune | block6 + top_conv unfrozen (BN frozen) | DiscriminativeAdamW (block6=0.1Γ—) | 3e-4 + CosineDecay + Warmup 5ep | 50 | 7 (best=2) + 10 SWA | No | 0.05 |
225
 
226
+ > ΒΉ Phase 1 uses `EarlyStopping` with `patience=5` on `val_accuracy`. Ran 25 epochs (maximal), best epoch = 23 (val_accuracy 97.54%). EarlyStopping was not triggered β€” model kept improving within every 5-epoch window.
227
 
228
+ > Β² Phase 2 uses `EarlyStopping` with `patience=3` on `val_accuracy`, followed by 10 SWA epochs (constant LR 1e-4).
229
 
230
  ### Hyperparameters
231
 
 
239
  | LR Multiplier (top_conv+head) | β€” | 1.0Γ— |
240
  | Loss | FocalLoss (gamma=2.0, LS=0.1) | FocalLoss (gamma=2.0, LS=0.05) |
241
  | Batch Size | 32 | 32 |
242
+ | Early Stopping Patience | 5 | 3 |
 
243
  | EMA Decay (per-step) | 0.999 | 0.999 |
244
  | SWA Epochs | β€” | 10 (post-training) |
245
  | SWA LR | β€” | 1Γ—10⁻⁴ (constant) |
 
267
  | Random Erasing | p=0.5, area [0.02–0.15], aspect [0.3–3.3], applied pre-normalization | Zhong et al., AAAI 2020 |
268
  | Test-Time Augmentation | 6 augmentation variants, averaged | Shanmugam et al., ICML 2020 |
269
  | WarmupCosineDecay | Linear warmup + cosine annealing | Loshchilov & Hutter, ICLR 2017 (SGDR) |
270
+ | Early Stopping | Patience 5 and 3 (Phase 1 and Phase 2), monitor val_accuracy | Prechelt, Neural Networks 1998 |
271
 
272
  ### Dataset
273
 
 
290
 
291
  | Category | Files |
292
  |----------|-------|
293
+ | **Model (best)** | `fine_tuning_swa.keras` (226.75 MB) Β· `.weights.h5` (158.31 MB) Β· `.safetensors` (157.10 MB) |
294
+ | **Code** | `build_model.py` (20.7 KB) β€” architecture + CLI inference |
295
  | **Config** | `config.json` Β· `label_mapping.json` Β· `preprocessor_config.json` |
296
  | **Evaluation** | `calibration_data.json` Β· `model_benchmark.json` Β· `confusion_pairs.json` Β· `class_confidence_stats.json` Β· `temperature_config.json` |
297
+ | **Deployment** | `saved_model/` (183.29 MB, saved_model.pb: 5030.8 KB) Β· `tflite/` (88.36 MB) Β· `tfjs_model/` (89.54 MB, 23 shards) |
298
+ | **Results** | `results/` β€” 13 PNG (augmentation, resolution distribution, training curves, confusion matrix, ROC, t-SNE, Grad-CAM, etc.) |
299
  | **Archive** | `models_keras/` β€” 3 checkpoints (head_training, fine_tuning, fine_tuning_ema) |
300
 
301
  ## Usage
 
461
 
462
  | Metric | Result |
463
  |--------|--------|
464
+ | Keras correct | 7/8 (88%) β€” 1,316/1,344 test samples |
465
+ | TFLite correct | 7/8 (88%) β€” 1,316/1,344 test samples |
466
  | Keras vs TFLite match | **8/8 (100%)** β€” identical predictions |
467
+ | Keras inference speed | 437.5 ms |
468
+ | TFLite inference speed | 197.8 ms |
469
 
470
+ > The 1 misclassification (castle→bridge, 41.9% confidence) is consistent with the 97.92% test accuracy. The 8/8 match confirms TFLite conversion preserves model behavior exactly.
471
 
472
  ![TFLite Inference](results/inference_tflite.png)
473
 
 
493
 
494
  | Format | File | Size | Protect AI | Inference Speed | Best For |
495
  |--------|------|------|------------|-----------------|----------|
496
+ | **TF-Lite** βœ“ | `tflite/model.tflite` | ~88 MB | βœ“ Safe | **197.8 ms** (fastest) | Mobile, edge, embedded, HF Space |
497
  | **SavedModel** βœ“ | `saved_model/` | ~183 MB | βœ“ Safe | β€” | TensorFlow Serving, cloud backend |
498
  | **TFJS** βœ“ | `tfjs_model/` | ~90 MB | βœ“ Safe | β€” | Browser, Node.js (no backend) |
499
  | **Weights H5** βœ“ | `fine_tuning_swa.weights.h5` | ~158 MB | βœ“ Safe | β€” | Programmatic load via `build_model.py` |
500
  | **safetensors** βœ“ | `fine_tuning_swa.safetensors` | ~157 MB | βœ“ Safe | β€” | HF standard, cross-framework |
501
  | **Build Script** βœ“ | `build_model.py` | ~21 KB | βœ“ Safe | β€” | Architecture reconstruction + `load_weights()` |
502
+ | **Keras** β„Ή | `fine_tuning_swa.keras` | ~227 MB | β„Ή Flagged | 437.5 ms | Developer reference, fine-tuning |
503
 
504
  ### Load Examples
505