‘Person Blocker’ is a Python Script that Blocks Out Entire People in Images

Pranav Dar Last Updated : 02 Apr, 2018
2 min read

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!

 

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.

Responses From Readers

Clear

Santosh
Santosh

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.

Pablo
Pablo

Only I remember Black Mirror after read that article?

Congratulations, You Did It!
Well Done on Completing Your Learning Journey. Stay curious and keep exploring!

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details