Instructions to use MeghanaVP/car-subtype-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use MeghanaVP/car-subtype-classifier with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://MeghanaVP/car-subtype-classifier") - Notebooks
- Google Colab
- Kaggle
| # π Car Classification Model (196 Classes) | |
| ## π Overview | |
| This project implements a deep learning model for **fine-grained car classification** across **196 categories** using **TensorFlow/Keras** and an **EfficientNetB3 backbone**. | |
| The model uses custom preprocessing, advanced pooling (GeM), and strong data augmentation to improve performance. | |
| --- | |
| ## π§ Model Architecture | |
| * Backbone: **EfficientNetB3** | |
| * Input Shape: `(224, 224, 3)` | |
| * Output: `196 classes (softmax)` | |
| * Total Parameters: **11,755,251** | |
| ### Key Components: | |
| * Custom Layers: | |
| * `CastToFloat32` | |
| * `EfficientNetPreprocess` | |
| * `GeMPooling` | |
| * Data Augmentation: | |
| * Random Flip | |
| * Rotation | |
| * Zoom | |
| * Brightness & Contrast adjustment | |
| * Translation | |
| * Fully Connected Head: | |
| * Dense β BatchNorm β ReLU β Dropout | |
| * Final Softmax layer | |
| --- | |
| ## π Performance | |
| * **Accuracy: 80%** | |
| --- | |
| ## π Model Details | |
| * Weights file: `final_cars.keras` | |
| * Model is reconstructed programmatically and **weights are loaded separately** to avoid serialization issues with Lambda layers. | |
| --- | |
| ## βοΈ Usage | |
| ### 1. Load Model | |
| ```python | |
| from tensorflow.keras.models import load_model | |
| # Use the provided architecture code | |
| model.load_weights("final_cars.keras") | |
| ``` | |
| --- | |
| ### 2. Inference Example | |
| ```python | |
| import numpy as np | |
| from tensorflow.keras.preprocessing import image | |
| img = image.load_img("test.jpg", target_size=(224,224)) | |
| img = image.img_to_array(img) | |
| img = np.expand_dims(img, axis=0) | |
| predictions = model.predict(img) | |
| print(predictions) | |
| ``` | |
| --- | |
| ## ποΈ How It Works | |
| 1. Input image is augmented | |
| 2. Converted to float32 | |
| 3. Preprocessed using EfficientNet preprocessing | |
| 4. Passed through EfficientNetB3 backbone | |
| 5. Features pooled using **GeM pooling** | |
| 6. Fully connected layers perform classification | |
| --- | |
| ## π‘ Highlights | |
| * Avoids Lambda layer serialization issues using **custom registered layers** | |
| * Uses **GeM pooling** instead of traditional average pooling | |
| * Strong augmentation pipeline improves generalization | |
| --- | |
| ## π Notes | |
| * Ensure TensorFlow version compatibility when loading weights | |
| * Model expects input images resized to **224Γ224** | |
| --- | |
| ## π€ Author | |
| Meghana Poojary |