Git Product home page Git Product logo

liveness-detection's Introduction

Liveness Detection

This package includes the backend and a JavaScript frontend of a liveness detection application.

The application asks the user to perform a challenge: the user must move the nose to a random area shown on the screen. In the end, the following is verified: 1. there was one and only one face, 2. the user moved the nose to the target area, and 3. the user rotated the face.

Following there are some screenshots of a user performing the challenge:

screenshots

Following is the architecture of the application:

architecture

Setup

Prerequisites

  1. Configure the AWS Credentials in your environment. Refer to Configuration and credential file settings.

  2. Download and install AWS CLI. Refer to Installing the AWS CLI.

  3. Download and install AWS SAM CLI. Refer to Installing the AWS SAM CLI.

  4. Download and install Docker. Refer to Docker.

  5. Download and install Node.js. Refer to Node.js Downloads.

Backend

Run the command below to deploy the backend:

sam build --use-container && sam deploy --guided

The command above creates a CloudFormation stack with the following outputs: ApiUrl, StaticWebsiteUrl, and StaticWebsiteBucket. You need those values in the next steps.

Frontend

  1. Enter in the client/ directory.

  2. Download the ML models from face-api.js library:

curl -o public/weights/tiny_face_detector_model-shard1.shard -kL https://github.com/justadudewhohacks/face-api.js/blob/master/weights/tiny_face_detector_model-shard1?raw=true

curl -o public/weights/tiny_face_detector_model-weights_manifest.json -kL https://github.com/justadudewhohacks/face-api.js/blob/master/weights/tiny_face_detector_model-weights_manifest.json?raw=true

curl -o public/weights/face_landmark_68_model-shard1.shard -kL https://github.com/justadudewhohacks/face-api.js/blob/master/weights/face_landmark_68_model-shard1?raw=true

curl -o public/weights/face_landmark_68_model-weights_manifest.json -kL https://github.com/justadudewhohacks/face-api.js/blob/master/weights/face_landmark_68_model-weights_manifest.json?raw=true
  1. Change the models' paths in the manifests:
perl -i -pe 's/tiny_face_detector_model-shard1/tiny_face_detector_model-shard1.shard/g' public/weights/tiny_face_detector_model-weights_manifest.json

perl -i -pe 's/face_landmark_68_model-shard1/face_landmark_68_model-shard1.shard/g' public/weights/face_landmark_68_model-weights_manifest.json
  1. Open the .env file and replace the value of VUE_APP_API_URL with the API URL (ApiUrl) outputted during the backend deployment.

  2. Run the comamand below to build the frontend:

npm install && npm run build
  1. Copy the static frontend files with the following command (replace {YOUR_BUCKET} with the bucket name - StaticWebsiteBucket - outputted during the backend deployment):
aws s3 cp dist s3://{YOUR_BUCKET}/ --recursive

Open your browser and navigate to the CloudFront URL (StaticWebsiteUrl) outputted during the backend deployment.

Clean up (Optional)

If you don't want to continue using the application, take the following steps to clean up its resources and avoid further charges.

Empty the Amazon S3 buckets

Before you can delete a bucket, you must first delete its contents.

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3.

  2. In the Bucket name list, select the option next to the StaticWebsiteBucket and then choose Empty.

  3. On the Empty bucket page, confirm that you want to empty the bucket by entering the bucket name into the text field, and then choose Empty.

  4. In the Bucket name list, select the option next to the FramesBucket and then choose Empty.

  5. On the Empty bucket page, confirm that you want to empty the bucket by entering the bucket name into the text field, and then choose Empty.

Delete the CloudFormation stack

AWS CloudFormation makes it easy to clean up resources that the stack created. When you delete the stack, all resources that the stack created are deleted.

  1. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation.

  2. On the Stacks page in the CloudFormation console, select the stack you deployed during the Backend setup.

  3. In the stack details pane, choose Delete.

  4. Select Delete stack when prompted.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

liveness-detection's People

Contributors

amazon-auto avatar dependabot[bot] avatar hsfugita avatar mherna avatar rafaelwmartins avatar

Watchers

 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.