This project performs real-time object detection on a video using the YOLOv11n model with GPU acceleration. The processed video with bounding boxes and confidence scores is saved as an output file.
- Detect objects in a video using YOLOv11n.
- GPU acceleration with PyTorch.
- Draw bounding boxes with labels and confidence scores.
- Save processed video.
- Optional real-time display of processed frames.
- Python 3.12
- GPU with CUDA support for faster inference.
- Packages listed in
requirements.txt.
- Clone the repository:
git clone https://github.com/ayhmdalila/traffic-detection
cd traffic-detection- Install dependencies:
pip install -r requirements.txtRun the main script:
python main.pydocker run --gpus all -v $(pwd):/app yolo-video-detector- Make sure to mount the project directory to
/appin the container. - Ensure your GPU drivers and Docker NVIDIA runtime are properly set up.
- Frame size: Currently set to
640x360. - Frame skipping: Can skip frames by adjusting
frame_skip. - YOLO confidence threshold: Set via
confparameter (default 0.4). - IOU threshold: Set via
iouparameter (default 0.5).
- GPU is required for optimal performance.
- For CPU-only mode, remove
.to("cuda")inmain.py. - Supports
.mp4,.mkv, and other common video formats.
Open source
