API demo of running a Tensorflow model using FastAPI.
A sample of running ImageNet-based Resnet50 on Docker as a REST-API on FastAPI. API demo of running a Tensorflow model using FastAPI.
Qiitaに記載されているコードはこちら
- WSL2
- pipenv
- Docker
- tensorflow==2.3.0
- fastapi
- uvicorn
- Jinja
- aiofiles
- python-multipart
- opencv-python
All of these are listed in requirements_prod.txt.
$git clone https://github.com/T-Sumida/ml-api-fastapi.git
$cd ml-api-fastapi
$pipenv install
$pipenv run create
SavedModel will be output under models.
# build docker image
$pipenv run build
# start docker container
$pipenv run start
# stop docker container
$pipenv run stop
Go to http://localhost:8000/docs
For Authorize in the upper right corner of the docs, enter the value of API_KEY in the .env file.
T-Sumida