This project demonstrates real-time image classification using a webcam feed and the pre-trained MobileNetV2 model from TensorFlow Keras.
- Loads MobileNetV2 pre-trained on ImageNet.
- Captures live video from webcam.
- Classifies each frame in real-time.
- Displays predicted label and confidence score on screen.
- Press 'q' to quit.
Install dependencies before running the program:
pip install opencv-python tensorflow numpy
Run the script:
python RealTimeImageClassification.py
Press 'q' to exit the window.
.
βββ RealTimeImageClassification.py # Main script
βββ README.md # This documentation
- Loads MobileNetV2 with pre-trained ImageNet weights.
- Captures video from the webcam.
- Preprocesses each frame:
- Converts BGR β RGB
- Resizes to 224Γ224
- Applies MobileNetV2 preprocessing
- Passes the frame through the model.
- Displays the top predicted class with confidence score.
- MobileNetV2 -- Lightweight convolutional neural network optimized for real-time applications.
- Pre-trained on ImageNet (1,000 classes).
When you point the webcam at an object, you'll see:
Laptop : 95.2%
overlayed on the live feed.
- Ensure your webcam is accessible.
- First prediction might be slightly slower due to model loading.
- Works best in good lighting conditions.
Developed by Prithviraj Chavan.