You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

πŸš— TwinCar: Fine-Grained Car Classification (Stanford Cars 196)

This model predicts car make and model from images using a fine-tuned ResNet50 architecture, trained on the Stanford Cars 196 dataset.

Final project for Brainster Data Science Academy 2025.


πŸ“ Project Overview

  • Task: Classify car images into 196 make/model categories
  • Context: Automated vehicle inspection for TwinCar (drones/robots)
  • Input: RGB image (JPG/PNG, 224x224 or similar)
  • Output: Predicted car make/model (e.g., "BMW X5")
  • Production goal: Identify car brand/model for real-world inspection/automation

πŸ—οΈ Model Details

  • Architecture: ResNet50 (PyTorch, transfer learning, custom head)
  • Classes: 196 (make/model, see test_labels.csv)
  • Dataset: Stanford Cars 196
  • Training: 15 epochs, batch size 32, strong data augmentation
  • Authors: Kiril Mickovski & Team 3 (Brainster DSA)
  • License: MIT

Metrics & Results

Metric Value Description
Validation Accuracy 40.6% Correct predictions on the validation dataset
Training Accuracy 74.4% Correct predictions on the training dataset
Validation Loss 3.07 Cross-entropy loss on validation set
Training Loss 1.74 Cross-entropy loss on training set
Macro F1-score 0.38 Harmonic mean of precision and recall across all classes
Macro Precision 0.44 Average precision over all classes
Macro Recall 0.41 Average recall over all classes

Full per-class metrics: classification_report.csv


πŸ“Š Model Evaluation & Explainability

Below are selected screenshots and artifacts showcasing model evaluation, predictions, and explainability:


πŸ”΅ Confusion Matrix

Confusion Matrix


🟒 Training & Validation Curves

Loss & Accuracy Curves


🟣 F1, Precision, Recall Curves

F1, Precision, Recall


🟠 Top-20 Most Accurate Classes

Top-20 Accuracy


🟑 Top-20 Most Confused Classes

Top-20 Confused


πŸ”΄ Grad-CAM++ Examples (Explainability)

Model attention visualizations for interpretability (what parts of the image the model β€œlooks at”):

Grad-CAM++ 0 Grad-CAM++ 1 Grad-CAM++ 2


πŸ“‚ Files & Artifacts


πŸ› οΈ How to Reproduce

  1. Clone this repo or download weights and artifacts from above.
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Run the usage code (see Usage section above) or visit the GitHub repo for end-to-end training and evaluation.

⚠️ Limitations

  • Only 196 classes covered (see Stanford Cars dataset)
  • Performance may drop on night images, occlusions, or cars outside the 2010–2012 range
  • Trained for car make/model only (not year)

πŸ‘₯ Contributors

  • Kiril Mickovski
  • Team 3, Brainster Data Science Academy 2025

πŸ“œ Citation

Mickovski, K., Team 3 (2025). TwinCar: Fine-Grained Car Classification (Stanford Cars 196). Brainster Data Science Academy.


πŸ”— Resources


πŸ§‘β€πŸ’» Usage (PyTorch)

import torch
from torchvision import models, transforms
from PIL import Image

model = models.resnet50()
model.fc = torch.nn.Linear(model.fc.in_features, 196)
model.load_state_dict(torch.load("resnet50_finetuned.pth", map_location="cpu"))
model.eval()

transform = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
img = Image.open("your_image.jpg").convert("RGB")
input_tensor = transform(img).unsqueeze(0)

with torch.no_grad():
    logits = model(input_tensor)
    pred = logits.argmax(1).item()
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for kikogazda/TwinCar-196

Finetuned
(2)
this model

Dataset used to train kikogazda/TwinCar-196