A high-performance image classifier for watch recognition using Deep Learning and TensorFlow
- 🚀 High Performance: ~93-100% accuracy on test dataset
- ⚡ Lightning Fast: 8ms inference with TensorFlow Lite
- 📱 Mobile-Ready: Optimized 18.5MB model (91.7% smaller)
- 🔧 Easy to Use: Ready-to-use scripts for training and inference
- 📊 Complete Monitoring: Training plots and detailed metrics
| Metric | Original Model | TensorFlow Lite | Improvement |
|---|---|---|---|
| Size | 232.1 MB | 18.5 MB | 🎯 91.7% smaller |
| Speed | ~172ms | ~8.3ms | 🚀 15x faster |
| Accuracy | ~93-100% | 93.3% | ✅ Identical |
| Confidence | ~97% | 97.3% | ✅ Identical |
# Clone the repository
git clone https://github.com/toucdi/watch-classifier.git
cd watch-classifier
# Install dependencies
pip install -r requirements.txt# Test with optimized TensorFlow Lite model (included)
python classify_image.py sample_images/test_watch.jpg
# Multiple image test
python classify_image.py sample_images/*.jpgNote: The repository includes the optimized TensorFlow Lite model (18.5MB). For the full Keras model (232MB), run the training script or download from Releases.
# Organize your dataset in:
# dataset/train/watch/ and dataset/train/no_watch/
# dataset/test/watch/ and dataset/test/no_watch/
# Start training
python train_watch_classifier.pywatch-classifier/
├── 📄 README.md # Main documentation
├── 📄 requirements.txt # Python dependencies
├── 📄 LICENSE # MIT License
├── 📄 .gitignore # Git ignore file
│
├── 🐍 train_watch_classifier.py # Training script
├── 🐍 classify_image.py # Classification script
│
├── 📁 model/ # Trained models
│ ├── 📱 watch_classifier.tflite # TFLite model (18.5MB) - included
│ └── 🤖 watch_classifier.h5 # Keras model (232MB) - generate via training
│
├── 📁 dataset/ # Training dataset
│ ├── 📁 train/
│ │ ├── 📁 watch/ # Watch images (training)
│ │ └── 📁 no_watch/ # No-watch images (training)
│ └── 📁 test/
│ ├── 📁 watch/ # Watch images (testing)
│ └── 📁 no_watch/ # No-watch images (testing)
│
└── 📁 sample_images/ # Demo images for testing
├── 🖼️ test_watch.jpg
├── 🖼️ test_watch2.jpg
├── 🖼️ test_no_watch.jpg
├── 🖼️ test_no_watch2.jpg
└── 🖼️ test_no_watch3.jpg
# Single image
python classify_image.py path/to/image.jpg
# Multiple images
python classify_image.py img1.jpg img2.jpg img3.jpg
# With TensorFlow Lite model (faster)
python classify_image.py sample_images/test_watch.jpgModify train_watch_classifier.py to:
- Change model architecture
- Adjust hyperparameters
- Modify data augmentation
- Add custom callbacks
# CNN Optimized for watch recognition
- Conv2D (32 filters) + BatchNorm + MaxPooling + Dropout
- Conv2D (64 filters) + BatchNorm + MaxPooling + Dropout
- Conv2D (128 filters) + BatchNorm + MaxPooling + Dropout
- Conv2D (256 filters) + BatchNorm + MaxPooling + Dropout
- Flatten + Dense(512) + Dropout + Dense(1, sigmoid)
# Data Augmentation
- Random rotation
- Random zoom
- Horizontal flip
- Random shiftsTraining automatically generates:
- 📊 Loss and accuracy plots saved as images
- 🤖 Model checkpoints with best weights
- 📋 Detailed logs for each epoch
- 🛑 Early stopping to prevent overfitting
- Dataset: 2055 images per class (training) + 200 per class (testing)
- Training Accuracy: ~100%
- Test Accuracy: ~93-100%
- Average Confidence: >97%
- False Positives: <1%
- Hardware: MacBook with Apple Silicon
- Model .h5: ~172ms per image
- Model .tflite: ~8ms per image (🚀 15x faster)
- ✅ 91.7% size reduction
- ✅ 93.5% speed increase
- ✅ Compatible with mobile and edge devices
- 🔄 Transfer Learning with MobileNetV2
- ⚡ Model Pruning for further reduction
- 🎯 Quantization for embedded devices
Contributions welcome! Please:
- 🍴 Fork the repository
- 🔧 Create a feature branch (
git checkout -b feature/AmazingFeature) - 💾 Commit your changes (
git commit -m 'Add some AmazingFeature') - 📤 Push to the branch (
git push origin feature/AmazingFeature) - 🔍 Open a Pull Request
- 📸 Add new object categories
- 🚀 Performance optimizations
- 📱 Mobile app demo
- 🌐 Web interface
- 📊 Advanced metrics and visualizations
- Python: 3.8+
- TensorFlow: 2.10+
- RAM: Minimum 8GB for training
- Storage: ~500MB for complete dataset
- GPU: Optional but recommended for training
ImportError with tensorflow:
pip install --upgrade tensorflowMemory errors during training:
- Reduce
batch_sizeintrain_watch_classifier.py - Close other heavy applications
opencv-python issues on Apple Silicon:
pip install --upgrade --force-reinstall opencv-pythonThis project is released under MIT License. See the LICENSE file for details.
- TensorFlow Team for the excellent framework
- Keras Community for ease of use
- Open Source Community for inspiration
- 🐙 GitHub: toucdi
- 💬 Issues: GitHub Issues
⭐ If this project is useful to you, please leave a star! ⭐