This project implements real-time object detection using the YOLOv6 model in Python, leveraging OpenCV for video processing. The system can detect multiple objects from live webcam feeds or video files, providing high accuracy and efficiency.
- Real-Time Detection: Detect objects from a webcam feed or video file in real-time.
- Multiple Object Detection: Identifies multiple objects simultaneously with their respective confidence scores.
- Optimized with YOLOv6: Utilizes YOLOv6's pre-trained weights for high-speed and accurate detection.
- Customizable Parameters: Allows you to tweak confidence thresholds, image size, and more.
- A computer with a working webcam (if using webcam mode).
- A GPU is recommended for faster processing, but CPU mode is supported.
Ensure you have the following installed:
- Python 3.7+
- OpenCV
- PyTorch
- NumPy
You can install the required packages using the command below:
pip install -r requirements.txtDownload the YOLOv6 pre-trained weights from the YOLOv6 GitHub repository and place it in the root directory of this project. For example:
wget https://github.com/meituan/YOLOv6/releases/download/0.1/yolov6s.ptTo start real-time object detection from a webcam, use the following command:
python detect.py --weights yolov6s.pt --source 0Where --source 0 indicates the webcam feed. If you have multiple cameras, you can change the index (e.g., --source 1).
To run detection on a video file, use the following command:
python detect.py --weights yolov6s.pt --source path_to_video.mp4When the model runs, it will open a video feed showing real-time object detection with bounding boxes, labels, and confidence scores.