You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# [How to Perform YOLO Object Detection using OpenCV and PyTorch in Python](https://www.thepythoncode.com/article/yolo-object-detection-with-opencv-and-pytorch-in-python)
2
2
To run this:
3
3
-`pip3 install -r requirements.txt`
4
-
- Download the [model weights](https://pjreddie.com/media/files/yolov3.weights) and put them in `weights` folder.
5
4
- To generate a object detection image on `images/dog.jpg`:
6
5
```
7
-
python yolo_opencv.py images/dog.jpg
6
+
python yolov8_opencv.py images/dog.jpg
8
7
```
9
-
A new image `dog_yolo3.jpg` will appear which has the bounding boxes of different objects in the image.
8
+
A new image `dog_yolo8.jpg` will appear which has the bounding boxes of different objects in the image.
10
9
- For live object detection:
11
10
```
12
-
python live_yolo_opencv.py
11
+
python live_yolov8_opencv.py
13
12
```
14
13
- If you want to read from a video file and make predictions:
15
14
```
16
-
python read_video.py video.avi
15
+
python read_video_yolov8.py 1.mp4
17
16
```
18
17
This will start detecting objects in that video, in the end, it'll save the resulting video to `output.avi`
19
-
- If you wish to use PyTorch for GPU acceleration, please install PyTorch CUDA [here](https://pytorch.org/get-started) and use `yolo.py` file.
18
+
- Old files for YOLOv3: `yolo_opencv.py`, `live_yolo_opencv.py`, `read_video.py`
0 commit comments