This repository can be used to blur people from images or video. It uses Yolov3, pytorch and opencv.
Some initial configuration is required to run things. First we need to install all the python dependencies, and then download the network weights.
-
(Optional) If you want GPU acceleration, you've got two options. Either install pytorch with CUDA dependencies or install CUDA seperately.
-
After having activated your favorite virtual environment, install the required packages using
pip
by runningpip install -r requirements.txt
. You might wanted to consider installingnumpy
,scipy
andsklearn
libraries usingconda
, as they are compiled with CPU-specific optimizations which can speed things up quite a bit. -
Next up is downloading the YOLO network weights. You can do this by either download them here or by running
wget https://pjreddie.com/media/files/yolov3.weights
. Once the download is compete, place theyolov3.weights
in the weights folder.
usage: blur.py [-h] -i INPUT [-t OBJ_THRESH] [-n NMS_THRESH]
[--min-hits MIN_HITS] [--max-age MAX_AGE] [-o OUTDIR]
[-w] [--debug-trackers] [--cuda] [--no-show] [-c BLUR] [-b BLURCOLOR]
Object detection/blurring with YOLOv3
optional arguments:
-h, --help show this help message and exit
-i, --input INPUT input directory or video
-t, --obj-thresh OBJ_THRESH
objectness threshold, DEFAULT: 0.5
-n, --nms-thresh NMS_THRESH
non max suppression threshold, DEFAULT: 0.4
-o, --outdir OUTDIR output directory, DEFAULT: output/
-w, --webcam flag for detecting from webcam. Specify webcam ID in
the input. usually 0 for a single webcam connected
-c, --blurclasses What classes to blur, DEFAULT: ['person','truck', 'car','motorbike']
-b, --blurcolor What type of blur to use, DEFAULT: blur. Can also be a color, for black: (0,0,0)
This project wouldn't be possible without all the hard work on these projects: