Downloads · 30 days
0
Jordo23/vehicle-classifier
vehicle-classifier is a image classification model from Jordo23. Use it when you need a label for an image. It is set up for timm. The card lists the license as mit.
A fine-tuned EfficientNet-B4 model for identifying vehicle make, model, and year from photographs. Part of the "Dude, What's My Car?" vehicle identification system.
Downloads · 30 days
0
Access
Public
Updated Dec 14, 2025
Repo size
136 MB
Likes
8
Public
Click a slice to open those files.
.pth135 MB · 99%
From the Hugging Face model README
A fine-tuned EfficientNet-B4 model for identifying vehicle make, model, and year from photographs. Part of the "Dude, What's My Car?" vehicle identification system.
This model classifies vehicles into 8,949 unique classes covering make, model, and year combinations. It was trained on the VMMRdb (Vehicle Make and Model Recognition) dataset.
Make Model Year)Note: Vehicle classification is challenging due to subtle differences between model years and trim levels. Top-5 accuracy is more meaningful for practical applications.
| File | Format | Size | Description |
|---|---|---|---|
vehicle_classifier.pth | PyTorch | 130MB | Full checkpoint with weights + class mapping |
vehicle_classifier.onnx | ONNX | ~1MB | Optimized for fast inference |
class_mapping.csv | CSV | 346KB | Class ID to Make/Model/Year mapping |
import torch
import timm
from PIL import Image
from torchvision import transforms
# Load model
checkpoint = torch.load("vehicle_classifier.pth", map_location="cpu")
model = timm.create_model("efficientnet_b4", pretrained=False, num_classes=8949)
model.load_state_dict(checkpoint["model_state"])
model.eval()
# Preprocessing
transform = transforms.Compose([
transforms.Resize((380, 380)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
# Predict
image = Image.open("car.jpg").convert("RGB")
input_tensor = transform(image).unsqueeze(0)
with torch.no_grad():
logits = model(input_tensor)
probs = torch.softmax(logits, dim=1)
top5_probs, top5_indices = torch.topk(probs, 5)
# Decode predictions
class_mapping = checkpoint["class_mapping"] # {id: "Make Model Year"}
for prob, idx in zip(top5_probs[0], top5_indices[0]):
print(f"{class_mapping[idx.item()]}: {prob.item()*100:.1f}%")
import onnxruntime as ort
import numpy as np
from PIL import Image
# Load model
session = ort.InferenceSession("vehicle_classifier.onnx")
# Preprocess (same as PyTorch)
image = Image.open("car.jpg").convert("RGB").resize((380, 380))
img_array = np.array(image).astype(np.float32) / 255.0
img_array = (img_array - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]
img_array = img_array.transpose(2, 0, 1)[np.newaxis, ...]
# Predict
outputs = session.run(None, {"input": img_array.astype(np.float32)})
logits = outputs[0]
# Get top predictions
probs = np.exp(logits) / np.sum(np.exp(logits), axis=1, keepdims=True)
top5_indices = np.argsort(probs[0])[-5:][::-1]
from huggingface_hub import hf_hub_download
# Download model
model_path = hf_hub_download(repo_id="Jordo23/vehicle-classifier", filename="vehicle_classifier.pth")
onnx_path = hf_hub_download(repo_id="Jordo23/vehicle-classifier", filename="vehicle_classifier.onnx")
If you use this model, please cite:
@misc{vehicle-classifier-2024,
author = {Jordo23},
title = {Vehicle Classifier - Dude, What's My Car?},
year = {2024},
publisher = {Hugging Face},
url = {https://huggingface.co/Jordo23/vehicle-classifier}
}
MIT License - Free for personal and commercial use.
For issues or questions, please open an issue on the model repository.
Part of the "Dude, What's My Car?" vehicle identification system 🚗