This project implements Object Detection using the YOLO (You Only Look Once) algorithm, which is a fast and accurate deep learning model for object detection. YOLO divides the image into a grid, then predicts bounding boxes and probability scores for each region in the image.
In this project, we aim to detect objects from images or videos in real-time using the YOLO model. This repository provides an easy-to-use pipeline for training YOLO on your custom dataset or using pretrained weights for object detection.
This project uses YOLOv5/YOLOv8 (or any YOLO version your project is based on) for performing multi-class object detection tasks like detecting vehicles, pedestrians, animals, etc.
- Features
- Setup and Installation
- Usage Instructions
- Training YOLO on Custom Dataset
- Evaluating the Model
- Results
- Project Structure
- References
- Integration of YOLO for real-time object detection
- Easy setup for inference with pre-trained or custom models
- Supports both image and video input
- Custom dataset support for training (using YOLO configuration)
- Visualization of detection results (bounding boxes, labels, confidence scores)
- Uses PyTorch for GPU-based computation
Follow these steps to set up the project on your local machine:
-
Clone the repository:
git clone https://github.com/your-username/object_detection_with_yolo.git cd object_detection_with_yolo -
Set up a virtual environment (optional but recommended):
python -m venv yolo_env source yolo_env/bin/activate # On Windows use: yolo_env\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
The dependencies typically include:
torch: Deep learning framework for YOLO modelopencv-python: For image processingPyYAML: For configuration filesmatplotlib: For visualizing detection resultstqdm: For progress bars
-
Download pre-trained YOLO weights
- For YOLOv8 (depending on your YOLO version):
# Command to download weights for YOLOv8 model goes here
- For YOLOv8 (depending on your YOLO version):
-
Run YOLO detection on an image:
python detect.py --source path_to_image.jpg --weights path_to_yolov_weights.pt --output output_folder
-
Parameters:
--source: Path to the input image or folder containing images--weights: Path to YOLO model weights--output: Folder to store the output results- Other options include
--img-size,--conf-threshold,--iou-threshold, etc.
- Run YOLO detection on a video:
python detect.py --source path_to_video.mp4 --weights path_to_yolov_weights.pt --output output_folder
Once the model is trained, you can evaluate the performance using the validation set:
python val.py --weights path_to_weights.pt --data custom_data.yaml --task test- This will output metrics like [precision, recall, mAP (mean Average Precision)] for object detection performance.
Make sure to check these resources for better understanding and guidance.