Skip to content

Pytorch implementation of real time object detection algorithm YOLOv3

License

Notifications You must be signed in to change notification settings

zhaoyanglijoey/yolov3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLOv3

Pytorch implementation of real time object detection algorithm YOLOv3

Guided by YOLOv3 Pytorch implementation tutorial but has a better style and structure in my opinion

To run this detection algorithm, after cloning the repo, download pretrained weights by the authors to the repo directory here or by

wget https://pjreddie.com/media/files/yolov3.weights

Requirements

  • Pytorch 0.4
  • OpenCV 3.4

Usage

usage: detector.py [-h] -i INPUT [-t OBJ_THRESH] [-n NMS_THRESH] [-o OUTDIR]
                   [-v] [-w] [--cuda] [--no-show]

YOLOv3 object detection

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        input image or directory or video
  -t OBJ_THRESH, --obj-thresh OBJ_THRESH
                        objectness threshold, DEFAULT: 0.5
  -n NMS_THRESH, --nms-thresh NMS_THRESH
                        non max suppression threshold, DEFAULT: 0.4
  -o OUTDIR, --outdir OUTDIR
                        output directory, DEFAULT: detection/
  -v, --video           flag for detecting a video input
  -w, --webcam          flag for detecting from webcam. Specify webcam ID in
                        the input. usually 0 for a single webcam connected
  --cuda                flag for running on GPU
  --no-show             do not show the detected video in real time

To tune hyper parameters, change the cfg file.

Detecting on a image or a directory containing images

python3 detector.py -i <input>

Result will be save in <outdir>

demo

demo

demo

Detecting on a video or a webcam

  • Video python3 detector.py -i <input> -v
  • Webcam python3 detector.py -v -w -i 0

This will do object detection on the video or webcam(0 is the webcam ID. Change it if you have multiple webcam connected) and show the result in real time and save the detected video with bounding boxes flying around(without audio).

Note: Requires opencv. You might encounter a problem saying some function of opencv is not implemented. Try searching for a solution and reinstall your opencv package if needed(That is what I did). Add --no-show flag if you don't wanna see the result playing in real time or can't get opencv to work.

Note: Detection running on CPU is not fast enough to show the result in real time and you probably won't be able to see the video playing in normal speed. But the saved video will be in normal speed for detecting on a video because it processes all the frames. For webcam however, the speed will be much faster because it loses frames.

Reference

About

Pytorch implementation of real time object detection algorithm YOLOv3

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages