Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.15.1
metadata
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:
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 crop224x224, 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)ford (0.2654)nissan (0.1171) |
audi (0.7856)chevrolet (0.0776)volkswagen (0.0398) |
audi (0.9500) |
bmw.jpg |
bmw |
audi (0.5224)bmw (0.2075)ford (0.0745) |
bmw (0.9917)hyundai (0.0027)mercedes-benz (0.0021) |
bmw (0.9500) |
chevrolet.jpg |
chevrolet |
ford (0.2439)chevrolet (0.2244)volkswagen (0.1553) |
chevrolet (0.9625)ford (0.0171)dodge (0.0143) |
chevrolet (0.770) |
ford.jpg |
ford |
ford (0.3127)bmw (0.1521)audi (0.1196) |
ford (0.6104)chevrolet (0.1770)toyota (0.0921) |
ford (0.9700) |
honda.jpg |
honda |
honda (0.8067)toyota (0.0681)bmw (0.0375) |
toyota (0.4324)nissan (0.2534)hyundai (0.1611) |
honda (0.9300) |
hyundai.jpg |
hyundai |
hyundai (0.4650)audi (0.1100)toyota (0.0825) |
hyundai (0.4445)toyota (0.3217)nissan (0.1185) |
hyundai (0.800) |