Presenting Person Blocker: Now, using a pre-trained neural network you can automatically "block" people in images (like Black Mirror)

April 12, 2018, 2:49 p.m. By: Kirti Bakshi

Person Blocker

Here, you are now presented with a script that allows the user to automatically "block" people in images similar to the Black Mirror episode White Christmas, making the use of Mask R-CNN pre-trained on the MS COCO dataset. Also, there is no requirement for any GPU!

The user is allowed to block not only just people but a lot more than that: The user can block up to 80 different types of objects, that includes giraffes, busses and a lot more, hence, reducing its limitations!

Talking about its Setup:

This project relies on a handful of dependencies. The user can make the use of the following command in order to install the dependencies:

  • pip3 install -r requirements.txt

It is to note that Depending on the type of your environment, the user may need to make the use of sudo. One may also want to make the use of virtualenv.

Now, since we know the brief, moving onto its Usage:

Person Blocker is used from the following mentioned command line:

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

  • -i/--image: It specifies the image file.

  • -m/--model: It is the path to the pre-trained COCO model weights (default: current directory): if in case not specified, it will download them automatically to the current directory if not already present. Also, note that the weights are 258 MB.

  • -c/--color: It is the colour of the mask, in either quote-wrapped hexidecimal or 3-element RGB tuple format. (default: white)

  • -o/--object: It is the list of types of objects that are to be blocked (or object IDs of specific objects). The user can see the choices of objects that are allowed in order to block in or by making the use of the -names flag. (default: person)

  • -l/--labeled: It saves a labelled image that is annotated with detected objects and their object ID.

  • -n/--names: It prints the class options for objects, and then exits.

The script outputs two images: a static (pun intended) image person_blocked.png as well as an animated image person_blocked.gif like the one that is presented at the start of the article.

Given below is one example:

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

Person Blocker

Also, the Blocking of specific object(s) requires 2 steps as follows:

  • Running in inference mode in order to get the object IDs for each object,

  • And then blocking those object IDs.

What are its Requirements?

It has the same requirements as Mask R-CNN:

  • Python 3.4+

  • TensorFlow 1.3+

  • Keras 2.0.8+

  • Numpy, skimage, scipy, Pillow, cython, h5py

plus matplotlib and imageio

For More Information: Click Here