Giter VIP home page Giter VIP logo

lipreader's Introduction

Lip Reader

This is the branch for deployment code. Any push will automatically trigger Github Action CICD to containerize the repo, push the image to ECR, and deploy it on EC2. For development code, please refer to dev branch.

Directory

  • config/: app's central configuration

  • model/: model files

  • uploaded_videos/: two example videos

  • utils/:

    • face.py: get lip points from an image
    • video.py: get lip points from a video
    • predict.py: load model weights and predict
  • app.py: starting script for streamlit demo

  • Dockerfile: the docker file during containerization

  • .github/workflows/: the deployment file for github actions: containerize, push the image to ECR, deploy on EC2

Environment Requirement

Python >= 3.9

Local Development Setup

  1. Open a terminal and navigate to your project folder.

$ cd lipreader

  1. In your terminal, type:

$ python -m venv .venv

  1. A folder named ".venv" will appear in your project. This directory is where your virtual environment and its dependencies are installed.

  2. In your terminal, activate your environment with one of the following commands, depending on your operating system.

$ source .venv/bin/activate

  1. Download necessary packages

$ pip install -r requirements. txt

  1. Run your Streamlit app.

$ python -m streamlit run app.py

  1. To stop the Streamlit server, press Ctrl+C in the terminal.

  2. When you're done using this environment, return to your normal shell by typing:

$ deactivate

Local Docker Setup

  1. Generate requirements, (pipreqs only generate requirements for the current project)

$ pip install pipreqs

$ pipreqs . --ignore ".venv"

  1. Build image

$ docker build -t your-image-name:tag .

  1. Run image

$ docker run -d --name your-container-name -p 8501:8501 -v ~/.aws:/root/.aws your-image-name:latest

  1. Visit localhost:8501 in the browser

  2. Cleanup work: stop container

$ docker stop test-container

  1. Cleanup work: delete container

$ docker rm test-container

  1. Cleanup work: delete image

$ docker rmi <image_name>:<tag>

Demo Deployment steps

  1. Apply for an IAM user with Opensearchfullaccess and ECRfullaccess

  2. Create an EC2 instance and generate a key pair for SSH

  • Please meet model's basic hardware requirement
  • Please choose a pytorch version with cuda and pytorch preinstalled
  1. Create an ECR registry repo to store images

During configuration, please make the image is immutable!!

  1. Try SSH to the server (Follow this tutorial: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-linux-inst-ssh.html)

(1) $ chmod 400 key-pair-name.pem

(2) $ ssh -i /path/key-pair-name.pem instance-user-name@instance-public-dns-name

  1. SSH to your machine to make initial configurations.

(1) Install docker (Follow this tutorial: https://medium.com/@srijaanaparthy/step-by-step-guide-to-install-docker-on-amazon-linux-machine-in-aws-a690bf44b5fe)

(2) Add your user to the Docker group to run Docker commands without 'sudo':

$ sudo usermod -a -G docker ec2-user

After adding the user to the Docker group, simply disconnect and reconnect to SSH to refresh the group memberships.

(3) Configure AWS credentials on the server: $ aws configure, Input access key, secret key of the IAM user

(4) Log on to ECR on the server: please replace 123456789012.dkr.ecr.us-east-2.amazonaws.com/myapp with your ECR repository

$ aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-2.amazonaws.com/myapp

  1. Go to Github-project page - Settings - Secrets, add below key value pairs so that Github Actions would be able to fetch these configurations

lipreader's People

Contributors

mikkylok avatar

Watchers

 avatar Kostas Georgiou 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.