This repository contains scripts and resources for performing object detection using the YOLOv3 model with OpenCV. It includes pre-trained weights, configuration files, class labels, and a script to process and detect objects in images from a specified directory.
- Python 3.x
- OpenCV
- NumPy
-
Install the required Python packages:
pip install opencv-python numpy
-
Ensure that the
yolov3.weights
,yolov3.cfg
, andcoco.names
files are present in the directory.
Download the necessary files:
- yolov3.weights: https://pjreddie.com/media/files/yolov3.weights
- yolov3.cfg: https://github.com/pjreddie/darknet/blob/master/cfg/yolov3.cfg
- coco.names: https://github.com/pjreddie/darknet/blob/master/data/coco.names
-
Place your input images in the
images
directory. The script supports images with.jpeg
,.jpg
, and.png
extensions. -
Run the detection script:
python detect.py
-
The script will process each image in the
images
directory, perform object detection, and display the results with bounding boxes and labels.
-
Confidence Threshold: The confidence threshold for detecting objects is set to 0.3. You can adjust this value in the script to control the sensitivity of detections.
-
NMS Threshold: The Non-Maximum Suppression (NMS) threshold is set to 0.3. You can adjust this value in the script to control the overlap of bounding boxes.
-
Bounding Box Color: The color of the bounding boxes and labels is set to cyan. You can change this color in the script by modifying the
color
variable.
Here's an example of running the detection script and the output:
-
Place an image (
example.jpg
) in theimages
directory. -
Run the detection script:
python detect.py
-
The script will display the image with detected objects, bounding boxes, and labels.
This project is licensed under the MIT License. See the LICENSE file for details.