Giter Club home page Giter Club logo

opencv-background-removal-on-aws-lambda's Introduction

OpenCV Background Removal On AWS Lambda

OpenCV Background Removal Launch Stack

Serverless removal of images backgrounds with OpenCV, using an AWS Lambda.

Sample Human Image Input:

One women

Sample Human Image Output:

One women with background removed

OpenCV Background Removal on AWS Lambda uses a three step method to remove the background.

First, the python lambda function uses OpenCV's deep neural network (DNN) to identify areas of interest in the image. These areas are given as probability of being part of an object, a person or a dog for example. This results in a highly pixelated image if viewed.

Second, the area probabilities are inputed into the OpenCV GrabCut algorithm. GrabCut looks for edges to make more realistic cuts between the object and the background.

Finally, the image is smoothed using a Gaussian Blur.

Sample Dog Image Input:

Two dogs

Sample Dog Image Output:

Dogs with background removed

How to Use

  1. Click the "Image Background Removal Launch Stack" button:

OpenCV Background Removal Launch Stack

This will bring you to either the Cloudformation UI or the AWS console if you are not signed in. Sign in, if you are not already. From the Cloudformation UI, click "Next" at the bottom of the screen. Repeat clicking "Next" on the two following pages. You will reach a page with this towards the bottom:

CloudFormation Shot

 

Checkmark the three "I acknowledgement" statements and select "Create Stack." This will start building the CloudFormation stack. It may take several minutes for CloudFormation to finish.

 

  1. Navigate to S3. You should see a bucket named "mask-rcnn-demo-xxxxxxxx", where "xxxxxxxx" is the unique stack identifier from CloudFormation. Open this bucket. You will see an "index.html" file. Open this file. This webpage will appear:

OpenCV Background Removal Screen Shot

 

If you select the "Object Mask Options", you can control which object classes are used. The "Output Visualization Options" allows you to set a minimum confidence threshold for the OpenCV DNN model.

OpenCV Background Removal Menu Screen Shot

 

  1. Select a photo. Either select one of the stock photos or upload your own image. Select "Detect," if you uploaded an image or changed the image detection options.

OpenCV Background Removal Detection Screen Shot

 

  1. Congratulations! It's that easy.

 

Output File

OpenCV Background Removal on AWS Lambda returns a 32 bit png file. The png alpha channel is marked either transparent as 0 or visible as 255. The original image is stored in the RGB channels of the png file. This means you can visually restore sections of image by editing the alpha channel.

 

Questions

Any questions or suggestions, just add an "Issues" submission to this repository. Thanks.

 

Happy Coding!

opencv-background-removal-on-aws-lambda's People

Contributors

highpoint avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.