midlajvalappil's picture
Update README.md
32da6da verified

A newer version of the Streamlit SDK is available: 1.56.0

Upgrade
metadata
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

  1. Clone or download the project:

    cd "Object Detection using YOLO"
    
  2. Create and activate virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Run the application:

    streamlit run app.py
    
  5. Open 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

  1. Launch the application using streamlit run app.py
  2. 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
  3. Click "Start Detection" to begin real-time object detection
  4. 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:

  1. Check the troubleshooting section above
  2. Review the error messages in the application
  3. Ensure all requirements are met
  4. Try with different model/camera combinations

Happy Object Detecting! ๐ŸŽฏ