Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Simple web app example using streamlit and FastAPI to serve a PyTorch model

License

Notifications You must be signed in to change notification settings

riccardo1980/streamlit-fastapi-model-serving

 
 

Repository files navigation

streamlit-fastapi-model-serving

Fork of streamlit-fastapi-model-serving, see also this blogpost and PyConES 2020 video.

Put simply:

To run the example in a machine running Docker and docker-compose, run:

./download_models.sh
docker-compose build
docker-compose up

To visit the FastAPI documentation of the resulting service, visit http://localhost:8000 with a web browser.
To visit the streamlit UI, visit http://localhost:8501.

Logs can be inspected via:

docker-compose logs

Deployment

To deploy the app, one option is deployment on Heroku (with Dockhero). To do so:

  • rename docker-compose.yml to dockhero-compose.yml
  • create an app (we refer to its name as <my-app>) on a Heroku account
  • install locally the Heroku CLI, and enable the Dockhero plugin with heroku plugins:install dockhero
  • add to the app the DockHero add-on (and with a plan allowing enough RAM to run the model!)
  • in a command line enter heroku dh:compose up -d --app <my-app> to deploy the app
  • to find the address of the app on the web, enter heroku dh:open --app <my-app>
  • to visualize the api, visit the address adding port 8000/docs, e.g. http://dockhero-<named-assigned-to-my-app>-12345.dockhero.io:8000/docs(not https)
  • visit the address adding :8501 to visit the streamlit interface
  • logs are accessible via heroku logs -p dockhero --app <my-app>

Debugging

To modify and debug the app, development in containers can be useful (and kind of fun!).

About

Simple web app example using streamlit and FastAPI to serve a PyTorch model

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 77.3%
  • Shell 14.3%
  • Dockerfile 8.4%