Skip to content
💻 Using Mask R-CNN to blur the background of an image
Jupyter Notebook Python MATLAB Lua C++ C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__pycache__
assets
cocoapi-master
samples
LICENSE
README.md
coco.py
config.py
detect_and_blur.py
license.txt
model.py
parallel_model.py
requirements.txt
shapes.py
utils.py
visualize.py

README.md

Blur the background of an image

This project uses the Mask R-CNN algorithm to blur the background of an image leaving the object focused. The aim was to simulate the effect of the iPhone X or other phones camera when you are taking a selfie and it blurs the background leaving you as prettiest as you are (it doesn't do magic, I am sorry).

The Mask R-CNN was published March 2017, by the Facebook AI Research (FAIR).

This paper claims state of the art performance for detecting instance segmentation masks. If you want to know more, you can check the original paper.

Mask R-CNN implementation

This project uses the Mask R-CNN implementation from Matterport, Inc in Tensorflow and Keras, you can check it and please leave them a star in their repository.

A few changes have been made:

- A new function to take the mask and save in a new matrix the pixels where the objects are present.

- Perform the blurring and assign the original image values to the blurred pixels where the objects are present.

A Gaussian filter is applied in order to blur the image.

Requirements

Python 3.4, TensorFlow 1.3, Keras 2.0.8 and other common packages listed in requirements.txt.

To install requirements:

pip install -r requirements.txt

How to use

The main script is detect_and_blur.py. An example of execution would be as follows:

python3 detect_and_blur.py --input_name input_image.png --output_name blurred.png

It would save the new image in the location given.

Example

Example of blurred image

You can’t perform that action at this time.