Comparing AWS, Azure, and Heroku for ML Model Hosting - Hosting a Gender Detection model with Heroku

There are several options available to deploy your deep learning model to the cloud. Some of them are:
- Microsoft Azure
- Amazon Web Services
- Heroku
- Google Cloud
Each of these options has its own advantages and disadvantages that you may want to consider while hosting your application.
Heroku
Heroku does not require the user’s credit card details. You can host up to 5 free web apps on Heroku. Heroku Command Line Interface is really easy to use as well.
One disadvantage is the slug size has a hard limit of 500 MB, the soft limit being 300 MB. So if you have a 400–500 MB Deep learning model to host, you cannot do it with Heroku. The dependencies will have Tensorflow which itself is over 300MB, so forget about it.
Azure
Azure requires credit card details. Azure gives 200$ in free credit, which is only valid for a month. The Azure App service VS Code extension is amazing! It's super easy to use! You can literally deploy your application with a single click. However, except for testing, Azure will require payments.
University students look for free options. Microsoft Azure has a student subscription as well, which is free and doesn’t require credit card details. It comes with 100$ free credits which are valid for a year. The maximum zip size for Azure 2048 MB. However for the free tier only allows 1GB.
Amazon Web Services
AWS requires creating your instances and running the app as a docker image before hosting. AWS gives one year of free usage with limited free usage hours.
Tackling some common problems with Heroku
- The size of TensorFlow itself is 463MB. So, if there are more dependencies, the size will easily exceed 500MB. To tackle that instead of mentioning TensorFlow in the dependencies, mention TensorFlow-CPU. The size problem will be solved to some extent as the size of TensorFlow-CPU is less.
- If OpenCV is used, there is a persistent error from libGL.so. This error occurs during hosting. This error can be resolved in two ways.
- An Aptfile can be added with the dependencies.
- Update opencv-python to opencv-python-headless
- Some errors can arise due to the python version incompatibility. Add a runtime.txt file with the python version used in your local environment.
Hosting a Gender Detection API with Heroku
This model classifies an input image into either of the two classes — man or woman. To host with Heroku, you can do this :
git clone https://github.com/Soumi7/Gender_detection_API_for_SpeakUpWomen
Login to Heroku and create an app :
heroku loginheroku create <APPNAME>
Add your changes
git add .
Commit the changes ;
git commit -m “Heroku”
Push them :
git push heroku main
To fix issues, try :
heroku logs --tail.
Please leave a star on my Github if you found this useful.
References
More content at plainenglish.io