I forked a YOLOv4 inference script from 'erentknn' for both video and image files, easy to use and not complicated.
The edits in this fork add a 'mask_output' cropping the labels onto a black background.
python yolo_image.py -i street.jpg -o output.jpg -m mask_output.jpg
python yolo_video.py -i video.mp4 -o video_out.avi -m mask_output.avi
weights = glob.glob("yolo/*.weights")[0]
labels = glob.glob("yolo/*.txt")[0]
cfg = glob.glob("yolo/*.cfg")[0]
Change these lines in the script to your weights, labels and cfg files.
- Add custom training script
https://github.com/opencv/opencv/blob/master/samples/dnn/object_detection.py https://www.pyimagesearch.com/2020/06/01/opencv-social-distancing-detector/