Hristijan123 commited on
Commit
4ff2310
Β·
verified Β·
1 Parent(s): fa21433

Update model card for augmentation v2 final checkpoint

Browse files
Files changed (1) hide show
  1. README.md +171 -20
README.md CHANGED
@@ -1,9 +1,11 @@
1
  ---
2
  library_name: pytorch
 
3
  tags:
4
  - image-classification
5
  - computer-vision
6
  - vehicle-classification
 
7
  - pytorch
8
  - timm
9
  license: mit
@@ -11,32 +13,181 @@ license: mit
11
 
12
  # TwinCar Classifier
13
 
14
- TwinCar is a vehicle make and model recognition project developed for the Brainster Data Science Academy Machine Learning Final Project.
15
 
16
- ## Task
17
 
18
- The model predicts:
19
 
20
- - vehicle make
21
- - vehicle model
22
- - optionally production year
 
 
 
 
 
 
23
 
24
- ## Current status
25
 
26
- This repository is a placeholder for the final trained model and model card.
 
27
 
28
- Final contents will include:
29
 
30
- - model architecture
31
- - training dataset summary
32
- - validation metrics
33
- - robustness evaluation notes
34
- - usage instructions
35
- - limitations
36
- - links to GitHub, W&B, and demo Space
37
 
38
- ## Links
 
 
39
 
40
- - GitHub repo: https://github.com/Hristijan-kiko/twincar
41
- - W&B project: https://wandb.ai/hzlatevskii-brainster-data-science-academy/twincar
42
- - Demo Space: https://huggingface.co/spaces/twincar-group2/twincar-demo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: pytorch
3
+ pipeline_tag: image-classification
4
  tags:
5
  - image-classification
6
  - computer-vision
7
  - vehicle-classification
8
+ - fine-grained-classification
9
  - pytorch
10
  - timm
11
  license: mit
 
13
 
14
  # TwinCar Classifier
15
 
16
+ TwinCar is a vehicle make, model, and auxiliary year recognition project developed for the Brainster Data Science Academy Machine Learning Final Project.
17
 
18
+ The final deployed model is an EfficientNet-B3 classifier fine-tuned on Stanford Cars. It predicts one of 196 fine-grained Stanford Cars classes, then derives vehicle make, model, and year from the predicted class metadata.
19
 
20
+ ## Final deployed checkpoint
21
 
22
+ - **Checkpoint file:** `efficientnet_b3_stanford300_augv2_best.pt`
23
+ - **Architecture:** EfficientNet-B3
24
+ - **Input size:** 300 px
25
+ - **Classes:** 196 Stanford Cars fine-grained classes
26
+ - **Training data:** Stanford Cars training split
27
+ - **Training augmentation:** augmentation v2
28
+ - **Framework:** PyTorch + timm
29
+ - **Checkpoint manifest:** `checkpoint_manifest.json`
30
+ - **Current status:** final deployed candidate
31
 
32
+ The model repo also keeps older checkpoints for comparison and rollback:
33
 
34
+ - `efficientnet_b3_stanford300_best.pt` β€” previous EfficientNet-B3 checkpoint
35
+ - `best.pt` β€” older ResNet18 baseline checkpoint
36
 
37
+ ## What the model predicts
38
 
39
+ The model directly predicts a fine-grained class, for example:
 
 
 
 
 
 
40
 
41
+ ```text
42
+ Dodge Charger SRT-8 2009
43
+ ```
44
 
45
+ From that fine-grained prediction, the system derives:
46
+
47
+ - **make** β€” e.g. `Dodge`
48
+ - **model** β€” e.g. `Charger SRT-8`
49
+ - **year** β€” e.g. `2009`
50
+
51
+ Year is included as an auxiliary output, but it is not predicted by a separate year-regression or year-classification head. It is derived from the predicted fine-grained class metadata.
52
+
53
+ ## Validation results
54
+
55
+ Final quantitative comparison is reported on the locked Stanford validation split using the same evaluation protocol for all compared models.
56
+
57
+ | Transform | Fine acc | Make acc | Model acc | Year acc | Top-3 acc | Top-5 acc |
58
+ | ---------------- | -------: | -------: | --------: | -------: | --------: | --------: |
59
+ | clean | 0.7864 | 0.8692 | 0.7925 | 0.8913 | 0.9196 | 0.9521 |
60
+ | robust_light | 0.7882 | 0.8680 | 0.7944 | 0.8956 | 0.9159 | 0.9490 |
61
+ | robust_hard | 0.6839 | 0.7778 | 0.6900 | 0.8355 | 0.8600 | 0.9055 |
62
+ | robust_occlusion | 0.6317 | 0.7317 | 0.6366 | 0.8048 | 0.8060 | 0.8600 |
63
+
64
+ The augmentation-v2 EfficientNet-B3 model improved both clean validation accuracy and robustness compared with the earlier EfficientNet-B3 candidate.
65
+
66
+ ## Robustness evaluation
67
+
68
+ The final model was evaluated under multiple image transforms:
69
+
70
+ - **clean** β€” standard validation preprocessing
71
+ - **robust_light** β€” mild production-like perturbations
72
+ - **robust_hard** β€” stronger blur, lighting, color, and geometric perturbations
73
+ - **robust_occlusion** β€” synthetic occlusion/erasing stress test
74
+
75
+ These tests are not a replacement for real-world field validation, but they quantify how the model behaves under controlled distribution shifts.
76
+
77
+ ## CompCars status
78
+
79
+ CompCars was inspected and used for external validation and reconnaissance, but it was not blindly merged into final training.
80
+
81
+ The main reason is that Stanford Cars and CompCars have a significant domain and label-distribution gap:
82
+
83
+ - Stanford Cars is a clean fine-grained benchmark with 196 make/model/year classes.
84
+ - CompCars contains different image domains and different make/model taxonomies.
85
+ - Exact Stanford Cars ↔ CompCars make/model/year overlap was too small and biased for safe blind merging.
86
+ - Make-level external validation on CompCars showed a strong cross-domain performance drop.
87
+
88
+ This confirmed that CompCars integration is a domain adaptation problem, not a simple data-merge task.
89
+
90
+ Future work should build a verified Stanford Cars ↔ CompCars alias map, train on a controlled filtered subset, and validate on a true cross-domain holdout.
91
+
92
+ ## Held-out Stanford test status
93
+
94
+ The local Stanford Cars test images were available and were used for qualitative API/demo smoke testing.
95
+
96
+ However, the available `cars_test_annos.mat` file contained only bounding boxes and filenames:
97
+
98
+ ```text
99
+ bbox_x1
100
+ bbox_y1
101
+ bbox_x2
102
+ bbox_y2
103
+ fname
104
+ ```
105
+
106
+ It did not include class labels.
107
+
108
+ The provided Kaggle mirror, `eduardo4jesus/stanford-cars-dataset`, was also checked. It included:
109
+
110
+ ```text
111
+ cars_meta.mat
112
+ cars_train_annos.mat
113
+ cars_test_annos.mat
114
+ ```
115
+
116
+ but did not provide:
117
+
118
+ ```text
119
+ cars_test_annos_withlabels.mat
120
+ cars_annos.mat
121
+ ```
122
+
123
+ Final quantitative model comparison is therefore reported on the locked Stanford validation split using an identical protocol and seed for every compared model. This keeps model-to-model deltas valid. A labeled held-out Stanford test evaluation would be a straightforward extension if `cars_test_annos_withlabels.mat` is obtained.
124
+
125
+ ## Demo
126
+
127
+ The model is deployed in a Hugging Face Space:
128
+
129
+ - **Demo Space:** [https://huggingface.co/spaces/twincar-group2/twincar-demo](https://huggingface.co/spaces/twincar-group2/twincar-demo)
130
+
131
+ The Space supports:
132
+
133
+ - image upload
134
+ - webcam/clipboard input
135
+ - full-image prediction
136
+ - make/model/year display
137
+ - top-k predictions
138
+ - optional YOLO crop comparison mode
139
+
140
+ The YOLO cropper is experimental and default-off. The official prediction remains the full-image EfficientNet-B3 prediction.
141
+
142
+ ## API and code
143
+
144
+ Project repository:
145
+
146
+ - **GitHub:** [https://github.com/Hristijan-kiko/twincar](https://github.com/Hristijan-kiko/twincar)
147
+
148
+ The GitHub repo includes:
149
+
150
+ - reusable Python package
151
+ - FastAPI inference endpoint
152
+ - Gradio demo app
153
+ - batch prediction script
154
+ - training and evaluation scripts
155
+ - robust evaluation reports
156
+ - CI with linting and tests
157
+
158
+ ## W&B
159
+
160
+ Training and experiment tracking:
161
+
162
+ - **W&B project:** [https://wandb.ai/hzlatevskii-brainster-data-science-academy/twincar](https://wandb.ai/hzlatevskii-brainster-data-science-academy/twincar)
163
+
164
+ ## Intended use
165
+
166
+ This model is intended for educational and prototype-level vehicle recognition experiments, especially make/model classification from car images similar to Stanford Cars.
167
+
168
+ Appropriate uses:
169
+
170
+ - fine-grained vehicle make/model recognition demo
171
+ - model comparison and robustness analysis
172
+ - prototype vehicle inspection workflow
173
+ - academic/academy project demonstration
174
+
175
+ ## Limitations
176
+
177
+ - The final model is trained on Stanford Cars, not on real drone/robot production footage.
178
+ - CompCars showed a strong domain gap and was not blindly merged into final training.
179
+ - True top-down drone views remain out-of-distribution.
180
+ - Robustness tests use controlled synthetic perturbations, not full real-world field validation.
181
+ - Year is derived from the fine-grained class label metadata, not learned as an independent year model.
182
+ - The system assumes the uploaded image contains a vehicle.
183
+ - Strong non-car/out-of-distribution rejection is not implemented yet.
184
+ - Similar models and years can be confused because fine-grained vehicle classification often depends on subtle visual details.
185
+
186
+ ## Future work
187
+
188
+ - Build a verified Stanford Cars ↔ CompCars alias map.
189
+ - Fine-tune on a controlled CompCars surveillance subset.
190
+ - Add real production/drone/robot images for target-domain validation.
191
+ - Add non-car/out-of-distribution rejection.
192
+ - Add detector-assisted preprocessing as a validated default only if it improves real metrics.
193
+ - Explore multi-head prediction for make/model/year if independent outputs become necessary.