EfficientNetB0 Stanford Cars Classifier

A TensorFlow/Keras image-classification model for fine-grained recognition of 196 make-model-year vehicle classes.

Model details

  • Architecture: EfficientNetB0
  • Initial weights: ImageNet
  • Input size: 224 × 224 RGB
  • Output: 196-class softmax
  • Model format: Keras .keras
  • Framework: TensorFlow 2.20
  • Model size: 43.77 MB

The original EfficientNet classification head was removed and replaced with global average pooling, batch normalization, dropout, and a 196-class softmax layer.

Training was performed in three stages:

  1. Training the new classification head with a frozen backbone.
  2. Fine-tuning the final 30 EfficientNetB0 layers.
  3. Fine-tuning on a mixture of bounding-box crops and full images.

Training data

The model was trained using the Stanford Cars dataset downloaded from:

https://www.kaggle.com/datasets/eduardo4jesus/stanford-cars-dataset

The dataset contains 16,185 images and 196 fine-grained vehicle classes. Class labels generally include make, model, body style, and model year.

Only the 8,144 labeled training images were used. They were divided with a stratified custom split:

Split Images
Train 6,515
Validation 814
Test 815

The original 8,041 test images were not used for quantitative evaluation because the downloaded annotations did not contain class labels.

Preprocessing

  1. Decode the image as RGB.
  2. Convert pixels to float32 in the [0, 255] range.
  3. Resize to 224 × 224 using padding while preserving aspect ratio.
  4. Do not manually divide pixel values by 255. EfficientNetB0 contains its own input rescaling.

The final training stage used a mixture of:

  • full images;
  • bounding-box crops with a 15% margin.

Evaluation

The final model was evaluated on 815 full, uncropped test images.

Metric Value
Full-image top-1 accuracy 48.83%
Full-image top-5 accuracy 75.71%
Selective accuracy 69.14%
Selective coverage 52.88%

Selective prediction uses:

  • minimum top-1 confidence: 0.60;
  • minimum top-1/top-2 margin: 0.10.

Predictions below either threshold should be returned as Unknown / unsupported.

Intended use

The model is intended for educational projects and prototype vehicle recognition systems. It can be used as the first stage of a pipeline that estimates a vehicle price from the predicted make, model family, and year.

Limitations

  • The model recognizes only the 196 classes present in Stanford Cars.
  • Many modern vehicles are absent from the dataset.
  • It cannot reliably identify an unseen model.
  • Similar generations, trims, and body styles are frequently confused.
  • Performance depends on viewpoint, visibility, background, and image quality.
  • Confidence thresholds reduce incorrect answers but are not a guaranteed out-of-distribution detector.
  • This model does not predict price by itself.

For example, BMW 2 Series G42 is not represented in the training classes and should be treated as unsupported.

Loading the model

import tensorflow as tf

model = tf.keras.models.load_model(
    "car_classifier.keras"
)
Downloads last month
25
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support