samuelsaettler
Update Space app, README, examples, and lightweight model artifacts
28f4585
---
title: Gradio Car Classification App
emoji: "🚗"
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: "6.11.0"
python_version: "3.11"
app_file: app.py
pinned: false
---
# Gradio Car Classification App
This app compares 3 image classification approaches on car images:
- Fine-tuned transfer learning model (SqueezeNet) trained on a custom car dataset
- Zero-shot CLIP (`openai/clip-vit-base-patch32`)
- OpenAI vision model (LLM image classification)
## Dataset Used For Training
- Hugging Face dataset loader: `load_dataset("tanganke/stanford_cars")`
- Original dataset reference: Stanford Cars
- Number of classes used in this project: `12`
- Classes: `audi`, `bmw`, `chevrolet`, `dodge`, `ford`, `honda`, `hyundai`, `mercedes-benz`, `nissan`, `tesla`, `toyota`, `volkswagen`
Dataset preparation command:
```bash
python3 prepare_car_dataset.py --reset \
--brands audi bmw chevrolet ford honda hyundai mercedes-benz nissan tesla toyota volkswagen dodge \
--train-per-brand 120 \
--test-per-brand 30 \
--image-size 256
```
## Preprocessing Steps
- Train transform: random resized crop `224x224`, random horizontal flip, ImageNet normalization
- Validation/Test transform: resize `256`, center crop `224x224`, ImageNet normalization
- Inference (`app.py`): same ImageNet normalization as training/evaluation
## Trained Model
- Hugging Face model link: `https://huggingface.co/saettsam/car-classification-model`
- Local output directory: `models/custom_resnet18/`
- Architecture: `squeezenet1_1`
## Application Link
- Hugging Face Space link: `https://huggingface.co/spaces/saettsam/car-classification-model`
## Training Performance
| Training Loss | Epoch | Validation Loss | Accuracy |
|---:|---:|---:|---:|
| 2.5523 | 1 | 2.3256 | 0.2208 |
| 2.2068 | 2 | 2.1537 | 0.3042 |
| 1.9677 | 3 | 1.9918 | 0.3583 |
| 1.8091 | 4 | 1.8408 | 0.4125 |
| 1.6791 | 5 | 1.6751 | 0.4500 |
| 1.5624 | 6 | 1.5332 | 0.5333 |
## Example Image Results
The table below reports the true class and Top-3 predictions for the custom model and CLIP.
| Image | True Class | Custom Top-3 (score) | CLIP Top-3 (score) | OpenAI LLM (label, confidence) |
|---|---|---|---|---|
| `audi.jpg` | `audi` | `audi` (0.2694)<br>`ford` (0.2654)<br>`nissan` (0.1171) | `audi` (0.7856)<br>`chevrolet` (0.0776)<br>`volkswagen` (0.0398) | `audi` (0.9500) |
| `bmw.jpg` | `bmw` | `audi` (0.5224)<br>`bmw` (0.2075)<br>`ford` (0.0745) | `bmw` (0.9917)<br>`hyundai` (0.0027)<br>`mercedes-benz` (0.0021) | `bmw` (0.9500) |
| `chevrolet.jpg` | `chevrolet` | `ford` (0.2439)<br>`chevrolet` (0.2244)<br>`volkswagen` (0.1553) | `chevrolet` (0.9625)<br>`ford` (0.0171)<br>`dodge` (0.0143) | `chevrolet` (0.770) |
| `ford.jpg` | `ford` | `ford` (0.3127)<br>`bmw` (0.1521)<br>`audi` (0.1196) | `ford` (0.6104)<br>`chevrolet` (0.1770)<br>`toyota` (0.0921) | `ford` (0.9700) |
| `honda.jpg` | `honda` | `honda` (0.8067)<br>`toyota` (0.0681)<br>`bmw` (0.0375) | `toyota` (0.4324)<br>`nissan` (0.2534)<br>`hyundai` (0.1611) | `honda` (0.9300) |
| `hyundai.jpg` | `hyundai` | `hyundai` (0.4650)<br>`audi` (0.1100)<br>`toyota` (0.0825) | `hyundai` (0.4445)<br>`toyota` (0.3217)<br>`nissan` (0.1185) | `hyundai` (0.800) |