Instructions to use Dmustache/autosnap-car-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Dmustache/autosnap-car-model with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://Dmustache/autosnap-car-model") - Notebooks
- Google Colab
- Kaggle
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:
- Training the new classification head with a frozen backbone.
- Fine-tuning the final 30 EfficientNetB0 layers.
- 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
- Decode the image as RGB.
- Convert pixels to
float32in the[0, 255]range. - Resize to
224 × 224using padding while preserving aspect ratio. - 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