minimaxir / person-blocker

Automatically "block" people in images (like Black Mirror) using a pretrained neural network.
Other
2.02k stars 212 forks source link

Person Blocker

img4

A script to automatically "block" people in images (like the Black Mirror episode White Christmas) using Mask R-CNN pretrained on the MS COCO dataset. No GPU required!

But you can block more than just people: up to 80 different types of objects can be blocked, including giraffes and busses!

Setup

This project relies on a handful of dependencies, use the following command to install your dependencies:

pip3 install -r requirements.txt

Note: Depending on your environment, you may need to use sudo. You may also want to use virtualenv.

Usage

Person Blocker is used from the command line:

python3 person_blocker.py -i images/img3.jpg -c '(128, 128, 128)' -o 'bus' 'truck'

The script outputs two images: a static (pun intended) image person_blocked.png and an animated image person_blocked.gif like the one at the beginning of this README.

Examples

python3 person_blocker.py -i images/img1.jpg

img1

python3 person_blocker.py -i images/img2.jpg -c '#c0392b' -o 'giraffe'

img2

python3 person_blocker.py -i images/img3.jpg -c '(128, 128, 128)' -o 'bus' 'truck'

img3

Blocking specific object(s) requires 2 steps: running in inference mode to get the object IDs for each object, and then blocking those object IDs.

python3 person_blocker.py -i images/img4.jpg -l

img4 labels

python3 person_blocker.py -i images/img4.jpg -o 1

img4

Requirements

The same requirements as Mask R-CNN:

plus matplotlib and imageio

Maintainer

Max Woolf (@minimaxir)

Max's open-source projects are supported by his Patreon. If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.

License

MIT

Code used from Mask R-CNN by Matterport, Inc. (MIT-Licensed), with minor alterations and copyright notices retained.