A real-time object detection system that combines YOLO (You Only Look Once) and Faster R-CNN for enhanced detection accuracy. This project demonstrates the power of ensemble methods in computer vision by merging predictions from two state-of-the-art object detection models.
- Hybrid Detection: Combines YOLO and Faster R-CNN predictions for improved accuracy
- Real-time Processing: Live camera feed with real-time object detection
- Multiple Views: Three display windows showing different detection methods
- Smart Merging: Uses IoU (Intersection over Union) to merge overlapping detections
- Non-Maximum Suppression: Eliminates duplicate detections for cleaner results
- Interactive Interface: Press 'q' to quit the application
- Color: Green bounding boxes
- Speed: Fast inference for real-time applications
- Accuracy: Good for general object detection
- Color: Blue bounding boxes
- Speed: Slower but more accurate
- Accuracy: Excellent for precise object localization
- Color: Red bounding boxes
- Method: Combines both models using IoU thresholding
- Result: Best of both worlds - speed and accuracy
- Python 3.8+
- OpenCV
- PyTorch
- Ultralytics
- Torchvision
-
Clone the repository
git clone https://github.com/divyanshsingh07/ObjectDetection.git cd ObjectDetection -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install torch torchvision ultralytics opencv-python
cd Code/yolo_project
source venv_new/bin/activate # Use existing virtual environment
python main.pycd Code/Custom
python main.py- Press 'q': Quit the application
- Camera: Automatically uses default camera (index 0)
Code/
├── yolo_project/ # Main project directory
│ ├── main.py # Main application with camera access
│ ├── initial.py # Initial implementation
│ ├── venv_new/ # Virtual environment
│ └── yolov5su.pt # YOLO model weights
├── Custom/ # Alternative implementation
│ ├── main.py # Custom version with camera access
│ └── initial.py # Initial custom implementation
├── data/ # Training data (ignored by git)
├── vehicle dataset/ # Vehicle detection dataset (ignored by git)
└── .gitignore # Git ignore rules
- YOLO: Single-stage detector for real-time performance
- Faster R-CNN: Two-stage detector for high accuracy
- Ensemble: Combines predictions using IoU-based merging
- GPU Acceleration: Supports CUDA for faster inference
- Batch Processing: Efficient frame processing pipeline
- Memory Management: Proper cleanup of OpenCV windows
The system can detect various objects including:
- People
- Vehicles (cars, trucks, buses)
- Animals
- Common objects (chairs, tables, etc.)
- And many more COCO dataset classes
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ultralytics for YOLO implementation
- PyTorch for deep learning framework
- OpenCV for computer vision operations
- Author: Divyansh Singh
- GitHub: @divyanshsingh07
- Project: ObjectDetection
⭐ Star this repository if you find it helpful!