Skip to content

woctezuma/heroku-clip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heroku CLIP

Illustration

Deploy OpenAI's CLIP on Heroku.

Usage

heroku login
heroku create
git push heroku main

If you have already deployed an app, then do not create it again after you have cloned the repo. Follow this instruction to add your remote instead. Typically, for myself:

heroku git:remote -a dry-taiga-80279

Results

Try the app on Heroku:

  • upload an image,
  • it will be resized to 224x224,
  • a prediction of the top-5 ImageNet labels (out of 1000) will be displayed.

If you want to try another image, make sure to first click on the red "X" to close the previous one:

How to close the previous image

Recommendations

First, to avoid using too much memory on Heroku:

  • ensure you don't store many variables and models in the global scope, use functions!
  • resize the input image, e.g. to 224x224 which is the resolution expected by CLIP anyway,

Otherwise, you will notice in logs that the app uses too much memory, or worse, crashes because of it:

Process running mem=834M(162.9%) Error R14 (Memory quota exceeded)

Second, the app is slow because it does not have access to a GPU on Heroku.

If a REST API is not required, I would recommend to use Colab instead:

  • the notebook can be user-friendly,
  • memory is less constrained,
  • a GPU will be available for free.

References

About

Deploy an API built with Streamlit on Heroku, in order to classify images.

Topics

Resources

License

Stars

Watchers

Forks