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! β