Skip to content

Latest commit

 

History

History
228 lines (172 loc) · 6.7 KB

File metadata and controls

228 lines (172 loc) · 6.7 KB

🕐 Watch Classifier

A high-performance image classifier for watch recognition using Deep Learning and TensorFlow

License: MIT Python 3.8+ TensorFlow 2.10+

🎯 Features

  • 🚀 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

📊 Model Performance

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

🚀 Quick Start

1. Installation

# Clone the repository
git clone https://github.com/toucdi/watch-classifier.git
cd watch-classifier

# Install dependencies
pip install -r requirements.txt

2. Instant Testing (with pre-trained model)

# 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/*.jpg

Note: The repository includes the optimized TensorFlow Lite model (18.5MB). For the full Keras model (232MB), run the training script or download from Releases.

3. Custom Training

# 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.py

📁 Project Structure

watch-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

💡 Advanced Usage

Classification Scripts

# 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.jpg

Custom Training Parameters

Modify train_watch_classifier.py to:

  • Change model architecture
  • Adjust hyperparameters
  • Modify data augmentation
  • Add custom callbacks

🔧 Model Architecture

# 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 shifts

📈 Training Monitoring

Training automatically generates:

  • 📊 Loss and accuracy plots saved as images
  • 🤖 Model checkpoints with best weights
  • 📋 Detailed logs for each epoch
  • 🛑 Early stopping to prevent overfitting

🎯 Performance Benchmark

Real Dataset Testing

  • Dataset: 2055 images per class (training) + 200 per class (testing)
  • Training Accuracy: ~100%
  • Test Accuracy: ~93-100%
  • Average Confidence: >97%
  • False Positives: <1%

Inference Speed

  • Hardware: MacBook with Apple Silicon
  • Model .h5: ~172ms per image
  • Model .tflite: ~8ms per image (🚀 15x faster)

🔬 Available Optimizations

TensorFlow Lite (Included)

  • ✅ 91.7% size reduction
  • ✅ 93.5% speed increase
  • ✅ Compatible with mobile and edge devices

Future Optimizations

  • 🔄 Transfer Learning with MobileNetV2
  • Model Pruning for further reduction
  • 🎯 Quantization for embedded devices

🤝 Contributing

Contributions welcome! Please:

  1. 🍴 Fork the repository
  2. 🔧 Create a feature branch (git checkout -b feature/AmazingFeature)
  3. 💾 Commit your changes (git commit -m 'Add some AmazingFeature')
  4. 📤 Push to the branch (git push origin feature/AmazingFeature)
  5. 🔍 Open a Pull Request

Contribution Ideas

  • 📸 Add new object categories
  • 🚀 Performance optimizations
  • 📱 Mobile app demo
  • 🌐 Web interface
  • 📊 Advanced metrics and visualizations

📋 Requirements

  • Python: 3.8+
  • TensorFlow: 2.10+
  • RAM: Minimum 8GB for training
  • Storage: ~500MB for complete dataset
  • GPU: Optional but recommended for training

🐛 Troubleshooting

Common Issues

ImportError with tensorflow:

pip install --upgrade tensorflow

Memory errors during training:

  • Reduce batch_size in train_watch_classifier.py
  • Close other heavy applications

opencv-python issues on Apple Silicon:

pip install --upgrade --force-reinstall opencv-python

📄 License

This project is released under MIT License. See the LICENSE file for details.

🌟 Acknowledgments

  • TensorFlow Team for the excellent framework
  • Keras Community for ease of use
  • Open Source Community for inspiration

📞 Contact


If this project is useful to you, please leave a star!