PersonalHard

Fine-Grained Car Recognition

Deep-learning study that recognises the exact car model in a photo: a CNN trained from scratch, 25 single-change ablations, and transfer learning where a ResNet pretrained on 1.25 million car photos reaches 92.2% on Stanford Cars, shipped in an on-device iOS demo.

— Overview

Architecture Overview

iOS demo

Notebook

Pretraining

Datasets

224 px, 92.2%

DVM-CAR
1.45M photos, 865 models

DVM-100
100 models

Stanford Cars
196 classes

Our ResNet
brand, model, year, colour heads

Task 1: CNN from scratch

Task 2: 25 single-change variants

Task 3: 6 transfer set-ups

YOLO finds the car

ONNX classifier names it

A solo deep-learning project for the AIDE500 course of a Data Engineering master's at the Lebanese University: recognise the exact model of a car from a photo, such as a BMW 3 Series rather than a 5 Series. It is fine-grained classification, where many classes share a design and differ only in a grille, a light or the proportions of the body.

The study follows the assignment's three tasks in one notebook. A plain 8-layer CNN trained from scratch on 100 car models sets the baseline at 67.0% test accuracy, against 1% for chance, and its mistakes are look-alike pairs of the same brand. Twenty-five variants then change one thing each, with the same data, seed and epoch budget, so every difference traces to that change: batch normalisation turns out essential (without it the network stays at chance), and removing layers costs far more than adding them gains.

The headline result is about where pretraining should come from. A ResNet trained from random weights on all of DVM-CAR, about 1.25 million advert photos, for roughly twelve hours, transfers to Stanford Cars far better than ImageNet's ResNet-18: 89.9% fine-tuned at 128 px against 73.6%, with four times fewer weights, and 92.2% at 224 px. It passes the from-scratch network's best accuracy after two epochs, and fine-tuned on a quarter of the data it still beats training from scratch on all of it. Each set-up was trained once, so the notebook treats differences of a point or two as noise rather than findings.

Key Features:

  • Splits grouped by advert, so photos of one car never sit in both training and test
  • Twenty-five single-change ablations across depth, kernels, downsampling, normalisation, activation, optimiser and learning rate, schedules, and augmentation including MixUp and CutMix
  • A multi-head ResNet pretrained on DVM-CAR for brand, model, year and colour, at 92.9% on 865 car models
  • Six transfer-learning set-ups compared on accuracy, convergence speed and data efficiency
  • Evaluation without bounding boxes, closer to a real user's photo (89.9% falls to 80.8%)
  • Logit adjustment for the long tail, where 224 of the 865 models have fewer than 20 photos
  • Flutter iOS demo: YOLO finds the car, and the 224 px network, exported to ONNX, names it on the device

Tech Stack:

  • Training: Python, PyTorch, torchvision, Apple Silicon (MPS)
  • Analysis: Jupyter, pandas, NumPy, Matplotlib
  • Data: DVM-CAR, Stanford Cars, ImageNet ResNet-18 weights
  • Mobile: Flutter with Cupertino widgets, Dart, ONNX Runtime, Ultralytics YOLO

University coursework, so the repository stays private.

— Stack
PythonPyTorchMachine LearningComputer VisionFlutterDartiOSDeep LearningJupyterONNXYOLOpandasNumPy