Skip to content

toucdi/watch-classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ• 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! ⭐

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages