Giter VIP home page Giter VIP logo

ml_project_template's Introduction

ml_project_template

Tutorial for deployment website in AWS instance can be found here

Tutorial

This is tutorial for local development on local machine

Install

sudo -s
apt update
apt install -y npm
apt install -y python3.6 python3-pip
apt install -y nginx
apt update && apt install -y libsm6 libxext6
apt install libxrender1
apt install -y redis-server

Clone the repo

apt install git
git clone https://github.com/thanhhau097/ml_project_template.git 

Install requirements

cd ml_project_template
alias python=python3
alias pip=pip3

Requirements for Flask app

cd api
pip install -r requirements.txt
npm install

Requirements for web app

cd ../web
npm install

Change your custom path

api/app.py

You need to config your AWS account in local machine: (optional, it is useful when you want to save uploaded data to AWS s3)

apt install awscli
aws configure

Change your bucket in AWS S3 (it is optional, when you need to upload user data to s3 bucket)

async_data = {
    'data': {'image': image_utils.encode(image), 'result': result},
    'bucket': 'your-bucket',
    'object_name': 'file-path-in-bucket/{}.pkl'.format(file_name)
}

nginx/nginx.conf

Comment out the SSL config in this file because you don't need domain name for local development (line 4-6, 29.41). If you want to deploy into production, please see this link.

Write your code

There are 3 tasks that you need to do for your project:

  1. Write prediction for you model in model/predictor.py and update your weights in model/weights folder
  2. Write your API in api/app.py using Flask framework (you can use the template that was written for image)
  3. Write your web app using ReactJS (you can use the demo template that I wrote in web/)

How to run the service

Open multiple terminal windows, each process should be handle in one window.

  1. Web
cd web/
npm run build
npm run start
  1. Flask
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export PYTHONPATH=$PYTHONPATH:./ 
python api/app.py 
  1. Redis

Change redis conf in /etc/redis/redis.conf

bind 0.0.0.0
systemctl stop redis
systemctl start redis
  1. Celery

Change 'redis://redis:6379/0' to 'redis://localhost:6379/0' because you are running redis in local machine

celery worker -A api.app.celery_app --loglevel=info
  1. Nginx

Change the app and web in nginx/nginx.conf file to 0.0.0.0

sudo -s
rm /etc/nginx/sites-enabled/default
cp nginx/nginx.conf /etc/nginx/sites-enabled/
systemctl reload nginx

Now you can go to your browser and see what is happening: 0.0.0.0

Tools are used in this template

  1. Flask
  2. Redis
  3. ReactJS
  4. Nginx
  5. Certbot (optional, when you have a domain name)
  6. Celery
  7. Docker
  8. Jenkins (optional)

ml_project_template's People

Contributors

dependabot[bot] avatar thanhhau097 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  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  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  avatar

ml_project_template's Issues

chào bạn

Mình nhớ là bạn có link youtube hướng dẫn đúng ko bạn? có thể cho mình xin link, vì giờ tìm không thấy bài trên face.
Cảm ơn!

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.