High-accuracy car viewpoint classification for mobile deployment
Live Demos:
- 🚀 Classification Demo → (Trained Model)
- 🔍 FAISS Similarity Demo → (MobileNet Features)
Pre-trained TFLite Model (Ready for Mobile Deployment)
- Download: viewpoint_classifier_float32.tflite 📦
- Size: 2.40 MB
- Accuracy: 87.22%
- Format: TensorFlow Lite (Float32)
- Input: 224×224×3 RGB images
- Output: 7 classes (6 viewpoints + unknown)
| Model | Size | Accuracy | Download Link |
|---|---|---|---|
| Float32 | 2.40 MB | 87.22% | Download |
| INT8 | 2.59 MB | ~85-87% | Download |
classes = ["front", "frontleft", "frontright", "rear", "rearleft", "rearright", "unknown"]import tensorflow as tf
import numpy as np
from PIL import Image
# Load model
interpreter = tf.lite.Interpreter(model_path="viewpoint_classifier_float32.tflite")
interpreter.allocate_tensors()
# Prepare image
image = Image.open("car.jpg").resize((224, 224))
image_array = np.array(image).astype(np.float32) / 255.0
image_array = np.expand_dims(image_array, axis=0)
# Run inference
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
interpreter.set_tensor(input_details[0]['index'], image_array)
interpreter.invoke()
predictions = interpreter.get_tensor(output_details[0]['index'])[0]
# Get result
classes = ["front", "frontleft", "frontright", "rear", "rearleft", "rearright", "unknown"]
predicted_class = classes[np.argmax(predictions)]
confidence = np.max(predictions)
print(f"Predicted: {predicted_class} ({confidence*100:.2f}%)")| Metric | Value |
|---|---|
| Overall Accuracy | 87.22% |
| Model Size | 2.40 MB |
| Parameters | 2.27M |
| Architecture | MobileNetV2 |
| Viewpoint | Accuracy |
|---|---|
| Front | 96.26% ⭐ |
| Front Right | 92.74% |
| Rear Left | 90.45% |
| Rear Right | 89.50% |
| Rear | 83.04% |
| Unknown | 82.57% |
| Front Left | 81.67% |
This project implements a 7-class car viewpoint classifier optimized for mobile deployment using TensorFlow Lite.
- Front - Front view of the car
- Front Right - Front-right diagonal view
- Front Left - Front-left diagonal view
- Rear - Rear view of the car
- Rear Right - Rear-right diagonal view
- Rear Left - Rear-left diagonal view
- Unknown - Invalid/unrecognized viewpoint
car_side_recog/
├── README.md # This file
├── docs/ # Additional documentation
│ ├── TRAINING_README.md # Training instructions
│ ├── CLASSIFICATION_RESULTS.md # Detailed results
│ └── VISUALIZATION_GUIDE.md # Visualization tools
├── train_viewpoint_classifier_fast.py # Main training script
├── resume_training.py # Resume from checkpoint
├── convert_tflite_final.py # TFLite conversion
├── test_predict.py # Inference script
├── requirements.txt # Python dependencies
├── class_map.json # Class label mapping
└── .gitignore # Git ignore rules
- Training Guide - How to train the model from scratch
- Classification Results - Detailed performance analysis
- Visualization Guide - Dataset visualization tools
# Clone the repository
git clone https://github.com/avinash064/Car_side_recog.git
cd Car_side_recog
# Install dependencies
pip install -r requirements.txt- Python 3.9+
- TensorFlow 2.10+
- NumPy
- Pillow
- scikit-learn
To train the model from scratch:
# Activate virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Run training
python train_viewpoint_classifier_fast.pyFor detailed training instructions, see Training Guide.
Convert your trained model to TFLite:
python convert_tflite_final.pyThe converted model will be saved to tflite_models/viewpoint_classifier_float32.tflite.
Run inference on test images:
python test_predict.py --image path/to/car_image.jpg- Input Shape:
[1, 224, 224, 3] - Input Type:
float32(normalized 0-1) - Output Shape:
[1, 7] - Output Type:
float32(softmax probabilities) - Preprocessing: Resize to 224×224, normalize to [0, 1]
If you use this model or code in your research, please cite:
@misc{car_viewpoint_classifier_2026,
author = {Avinash Kashyap},
title = {Car Viewpoint Classifier},
year = {2026},
publisher = {GitHub},
url = {https://github.com/avinash064/Car_side_recog}
}- Author: Avinash Kashyap
- GitHub: @avinash064
- Repository: Car_side_recog
This project is licensed under the MIT License - see the LICENSE file for details.
- MobileNetV2 architecture from TensorFlow
- Training dataset from CFV (Canonical Frontal View) dataset
- TensorFlow Lite for mobile optimization