TVect / mlops_demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Note: The purpose of the project to explore the libraries and learn how to use them. Not to build a SOTA model.

Requirements:

This project uses Python 3.8

Create a virtual env with the following command:

conda create --name project-setup python=3.8
conda activate project-setup

Install the requirements:

pip install -r requirements.txt

Running

Training

After installing the requirements, in order to train the model simply run:

python train.py

Monitoring

Once the training is completed in the end of the logs you will see something like:

wandb: Synced 5 W&B file(s), 4 media file(s), 3 artifact file(s) and 0 other file(s)
wandb:
wandb: Synced proud-mountain-77: https://wandb.ai/raviraja/MLOps%20Basics/runs/3vp1twdc

Follow the link to see the wandb dashboard which contains all the plots.

Versioning data

Refer to the blog: DVC Configuration

Exporting model to ONNX

Once the model is trained, convert the model using the following command:

python convert_model_to_onnx.py

Inference

Inference using standard pytorch

python inference.py

Inference using ONNX Runtime

python inference_onnx.py

Docker

Install the docker using the instructions here

Build the image using the command

docker build -t inference:latest .

Then run the container using the command

docker run -p 8000:8000 --name inference_container inference:latest

(or)

Build and run the container using the command

docker-compose up

Running notebooks

I am using Jupyter lab to run the notebooks.

Since I am using a virtualenv, when I run the command jupyter lab it might or might not use the virtualenv.

To make sure to use the virutalenv, run the following commands before running jupyter lab

conda install ipykernel
python -m ipykernel install --user --name project-setup
pip install ipywidgets

工具使用指南

wandb

https://docs.wandb.ai/quickstart

dvc + oss

https://dvc.org/doc/command-reference/remote/add

github actions

https://docs.github.com/cn/actions/quickstart

aliyun 函数计算 + aliyun ACR

  • 函数计算

https://help.aliyun.com/product/50980.html

这里的测试地址为:https://1008066561016311.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/mlops.LATEST/mlops_demo_inference/

  • 容器镜像服务 ACR

https://help.aliyun.com/product/60716.html

About


Languages

Language:Jupyter Notebook 65.5%Language:Python 32.7%Language:Dockerfile 1.8%