A newer version of the Streamlit SDK is available: 1.56.0
title: Real-time Object Detection With YOLO
emoji: ๐
colorFrom: red
colorTo: red
sdk: streamlit
app_file: src/streamlit_app.py
app_port: 8501
tags:
- streamlit
pinned: false
short_description: Streamlit template space
license: mit
๐ฏ Real-time Object Detection with YOLO
A comprehensive real-time object detection system built with YOLO (You Only Look Once) models, OpenCV, and Streamlit. This application provides an interactive web interface for detecting common objects from live webcam feeds with high performance and accuracy.
โจ Features
- Real-time Object Detection: Detect 80+ object classes in real-time from webcam feed
- Multiple YOLO Models: Support for YOLOv8 variants (Nano, Small, Medium, Large, Extra Large)
- Interactive Web Interface: User-friendly Streamlit interface with live controls
- Performance Optimization: Configurable detection intervals and performance settings
- Comprehensive Statistics: Real-time FPS, detection counts, and confidence metrics
- Error Handling: Robust error recovery and fallback mechanisms
- Configurable Settings: Adjustable confidence thresholds, camera selection, and display options
๐ Quick Start
Prerequisites
- Python 3.8 or higher
- Webcam or camera device
- At least 4GB RAM (8GB recommended for larger models)
Installation
Clone or download the project:
cd "Object Detection using YOLO"Create and activate virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtRun the application:
streamlit run app.pyOpen your browser and navigate to the URL shown in the terminal (typically
http://localhost:8501)
๐ System Requirements
Minimum Requirements
- CPU: Dual-core processor
- RAM: 4GB
- Storage: 2GB free space
- Camera: Any USB webcam or built-in camera
- OS: Windows 10+, macOS 10.14+, or Linux
Recommended Requirements
- CPU: Quad-core processor or better
- RAM: 8GB or more
- GPU: NVIDIA GPU with CUDA support (optional, for faster inference)
- Storage: 5GB free space
- Camera: HD webcam for better detection quality
๐ฎ Usage Guide
Getting Started
- Launch the application using
streamlit run app.py - Configure settings in the sidebar:
- Select YOLO model (start with YOLOv8 Nano for best performance)
- Adjust confidence threshold (0.5 is a good starting point)
- Choose your camera if multiple are available
- Click "Start Detection" to begin real-time object detection
- View results in the main video feed with bounding boxes and labels
Model Selection Guide
| Model | Speed | Accuracy | Use Case |
|---|---|---|---|
| YOLOv8n | โกโกโกโกโก | โญโญโญ | Real-time applications, low-end hardware |
| YOLOv8s | โกโกโกโก | โญโญโญโญ | Balanced performance |
| YOLOv8m | โกโกโก | โญโญโญโญโญ | Higher accuracy needs |
| YOLOv8l | โกโก | โญโญโญโญโญ | High accuracy, powerful hardware |
| YOLOv8x | โก | โญโญโญโญโญ | Maximum accuracy, research use |
Performance Tuning
- For better FPS: Use YOLOv8n model, increase detection interval
- For better accuracy: Use YOLOv8l or YOLOv8x, decrease confidence threshold
- For balanced performance: Use YOLOv8s with default settings
๐๏ธ Project Structure
Object Detection using YOLO/
โโโ app.py # Main Streamlit application
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ config.json # Configuration file (auto-generated)
โโโ src/
โ โโโ detection/
โ โ โโโ yolo_detector.py # YOLO detection logic
โ โ โโโ webcam_capture.py # Webcam handling
โ โโโ ui/
โ โ โโโ (future UI components)
โ โโโ utils/
โ โโโ config.py # Configuration management
โ โโโ helpers.py # Utility functions
โ โโโ error_handler.py # Error handling and recovery
โโโ tests/
โ โโโ (test files)
โโโ venv/ # Virtual environment
๐ง Configuration
The application supports various configuration options:
Detection Settings
- Model Selection: Choose from YOLOv8 variants
- Confidence Threshold: Minimum confidence for detections (0.1-1.0)
- Detection Interval: Process every N frames for performance
Camera Settings
- Camera Index: Select camera device
- Resolution: Frame width and height
- FPS Target: Target frames per second
Display Options
- Show FPS: Display current frame rate
- Show Statistics: Show detection statistics
- Show Confidence: Display confidence scores on detections
๐ Troubleshooting
Common Issues
Camera not detected:
- Ensure camera is connected and not used by other applications
- Try different camera indices (0, 1, 2, etc.)
- Check camera permissions
Model loading fails:
- Ensure stable internet connection for first-time model download
- Check available disk space (models can be 6-100MB)
- Try a smaller model first (YOLOv8n)
Low FPS performance:
- Use YOLOv8n model for fastest inference
- Increase detection interval
- Reduce camera resolution
- Close other resource-intensive applications
High memory usage:
- Use smaller YOLO models
- Reduce camera resolution
- Increase detection interval
Error Recovery
The application includes automatic error recovery for:
- Camera disconnection/reconnection
- Model loading failures
- Detection processing errors
๐ Detected Object Classes
The YOLO models can detect 80 different object classes including:
People & Animals: person, cat, dog, horse, sheep, cow, elephant, bear, zebra, giraffe, bird Vehicles: car, motorcycle, airplane, bus, train, truck, boat, bicycle Household Items: chair, couch, bed, dining table, toilet, tv, laptop, mouse, remote, keyboard Food & Drinks: bottle, wine glass, cup, fork, knife, spoon, bowl, banana, apple, sandwich Sports & Recreation: sports ball, kite, baseball bat, baseball glove, skateboard, surfboard And many more...
๐ค Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
๐ License
This project is open source and available under the MIT License.
๐ Acknowledgments
- Ultralytics: For the excellent YOLOv8 implementation
- Streamlit: For the amazing web app framework
- OpenCV: For computer vision capabilities
- PyTorch: For deep learning infrastructure
๐ Support
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Review the error messages in the application
- Ensure all requirements are met
- Try with different model/camera combinations
Happy Object Detecting! ๐ฏ