This repository is my project in Techainer Bootcamp 2022. The purpose of this project is to understand and practice how to serve and package a model, with the application of Mlchain, Dvc, Docker, and Streamlit.
Model weights can be download with: pip install 'dvc[gdrive]' && dvc pull
. Ask me if your google drive account does not have access to the weights folder yet
- Make sure to have mamba installed
- To create a conda env for CPU only machine, run:
mamba env create -f environment_cpu.yaml
- For GPU env, run:
mamba env create -f environment_gpu.yaml
- Then you can activate it with:
mamba activate face_classification_edit_cpu
ormamba activate face_classification_edit_cpu
accordingly.
- To build the deployment docker image for CPU env, run:
DOCKER_BUILDKIT=1 docker build -f cpu.Dockerfile -t face_classification_cpu .
- For GPU env, run:
DOCKER_BUILDKIT=1 docker build -f gpu.Dockerfile -t face_classification_gpu .
Activate the conda env then simply run:
mlchain run
- For CPU only env, run:
docker run --rm -it -p 9998:9998 face_classification_cpu
- For GPU env, please install
nvidia-docker
, then run:
docker run --gpus=all --rm -it -p 9998:9998 face_classification_gpu
Either case, an API server will be hosted at http://0.0.0.0:9998
To run the streamlit:
streamlit run streamlit/web.py
- To test the Python model, run:
python3 test.py
- To test the Python client, run:
python3 client.py
- To integrate this with your application, check out swagger interface at
/swagger
after you run the server. - To use the streamlit, add the image sample.png from the folder sample_data, or use any image sized 128x128.
If you have any question or encouter any problem regarding this repo. Please open an issue and cc me. Thank you.