Pranav Dar — April 2, 2018
AVbytes Python

Overview

  • Using ‘Person Blocker’ you can block out people and up to 80 other objects in images
  • The algorithm behind it uses Mask R-CNN that is pre-trained on the MS COCO dataset
  • The output gives us 2 images – one static and one animated

 

Introduction

We’ve all seen those edited videos paraded around in the news and movies where a person’s face is blacked out due to various reasons. You can now do the same on your machine by typing just a few lines of code!

A group of developers have created a python library called ‘Person Blocker’ that automatically blocks out entire people in images using a pre-trained neural network. The algorithm uses Mask R-CNN that is pre-trained on the MS COCO dataset. And the cherry on top? No GPU required!

And not just people, the algorithm is able to block out entire objects as well. The algorithm recognizes 80 different types of objects, including vehicles, animals, electronic gadgets, among other things. You can find the entire list in the ‘class.py’ file on GitHub (link given at the end of this section).

There are two steps associated with blocking objects in the image:

  • Running in inference mode to get the object IDs for each object
  • Blocking those object IDs

You can run Person Blocker from the command line itself:

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

The output of this is two-fold – a static image and an animated image.

There are a few dependencies attached to this library and we have listed them below:

  • Python 3.4+
  • TensorFlow 1.3+
  • Keras 2.0.8+
  • Numpy, skimage, scipy, Pillow, cython, h5py
  • matplotlib
  • imageio

You can view the GitHub repository for ‘Person Blocker’ here.

 

Our take on this

We tried out this library in python and we pretty impressed with the results. This will be a good go-to library for anyone getting into the image processing field. You can see below how the algorithm runs and the labels that are used to recognise objects in the image:

You can choose to block out anything in that image that has been labelled. Pretty impressive, isn’t it? Let us know in the comments below how it worked out for you.

 

Subscribe to AVBytes here to get regular data science, machine learning and AI updates in your inbox!

 

About the Author

Pranav Dar

Senior Editor at Analytics Vidhya. Data visualization practitioner who loves reading and delving deeper into the data science and machine learning arts. Always looking for new ways to improve processes using ML and AI.

Our Top Authors

  • Analytics Vidhya
  • Guest Blog
  • Tavish Srivastava
  • Aishwarya Singh
  • Ram Dewani
  • Faizan Shaikh
  • Aniruddha Bhandari

Download Analytics Vidhya App for the Latest blog/Article

3 thoughts on "‘Person Blocker’ is a Python Script that Blocks Out Entire People in Images"

Santosh
Santosh says: April 02, 2018 at 4:52 pm
Hey Dude, Thanks for sharing such a nice thing, but i wonder is it the same technology used to mask sensor things in a video. Reply
Pablo
Pablo says: April 13, 2018 at 5:43 pm
Only I remember Black Mirror after read that article? Reply
Pranav Dar
Pranav Dar says: April 13, 2018 at 5:57 pm
Hi Pablo, Yes! The concept was shown on the 'White Christmas' episode of Black Mirror. Reply

Leave a Reply Your email address will not be published. Required fields are marked *