Giter VIP home page Giter VIP logo

personblocker's Introduction

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'
  • -i/--image: specifies the image file.
  • -m/--model: path to the pretrained COCO model weights (default: current directory): if not specified, it will download them automatically to the current directory if not already present (note: the weights are 258 MB!)
  • -c/--color: color of the mask, in either quote-wrapped hexidecimal or 3-element RGB tuple format. (default: white)
  • -o/--object: list of types of objects to block (or object IDs of specific objects). You can see the allowable choices of objects to block in classes.py or by using the -names flag. (default: person)
  • -l/--labeled: saves a labeled image annotated with detected objects and their object ID.
  • -n/--names: prints the class options for objects, then exits.

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/kite.jpg

kite

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

giraffe

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:

  • Python 3.4+
  • TensorFlow 1.3+
  • Keras 2.1.6
  • Numpy, skimage, scipy, Pillow, cython, h5py

plus matplotlib and imageio

References

The credit for this code goes to @minimaxir. I've merely reproduced the results.

personblocker's People

Contributors

prabodhw96 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar paper2code - bot avatar

Forkers

junjunwang2016

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.