Heroku deployment

This Image captioning project, i uploaded code o github. When i deployed it in heroku it gives application error but works fine on local host. I am not able to get what the error is. So please help with this code- https://github.com/AshiKothari/Automated-Image-Captioning

hey @shinigami ,
can you please let me know what error are you getting on deployment.

2020-06-04T09:54:02.561385+00:00 app[web.1]: import tensorflow as tf
2020-06-04T09:54:02.561392+00:00 app[web.1]: ModuleNotFoundError: No module named ‘tensorflow’
2020-06-04T09:54:02.563768+00:00 app[web.1]: [2020-06-04 09:54:02 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-06-04T09:54:02.774051+00:00 app[web.1]: [2020-06-04 09:54:02 +0000] [4] [INFO] Shutting down: Master
2020-06-04T09:54:02.774251+00:00 app[web.1]: [2020-06-04 09:54:02 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-06-04T09:54:02.853265+00:00 heroku[web.1]: Process exited with status 3
2020-06-04T09:54:03.039115+00:00 heroku[web.1]: State changed from up to crashed
2020-06-04T09:54:08.000000+00:00 app[api]: Build succeeded
2020-06-04T09:54:30.944897+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=automated-image-captioning.herokuapp.com request_id=24cddfec-a48b-4b10-bda2-c532284474e3 fwd=“27.57.146.17” dyno= connect= service= status=503 bytes= protocol=https
2020-06-04T09:54:32.193876+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=automated-image-captioning.herokuapp.com request_id=ef9231b5-03ed-4819-8beb-7c429e1cadbc fwd=“27.57.146.17” dyno= connect= service= status=503 bytes= protocol=https

Well these are the logs. This was when i deployed it 5th time. Earlier it showed some gunicorn errors.
the 6th time:
-----> Python app detected
-----> Requirements file has been changed, clearing cached dependencies
-----> Installing python-3.6.10
-----> Installing pip
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting numpy
Downloading numpy-1.18.5-cp36-cp36m-manylinux1_x86_64.whl (20.1 MB)
Collecting pandas
Downloading pandas-1.0.4-cp36-cp36m-manylinux1_x86_64.whl (10.1 MB)
Collecting scikit-learn
Downloading scikit_learn-0.23.1-cp36-cp36m-manylinux1_x86_64.whl (6.8 MB)
Collecting matplotlib
Downloading matplotlib-3.2.1-cp36-cp36m-manylinux1_x86_64.whl (12.4 MB)
Collecting keras
Downloading Keras-2.3.1-py2.py3-none-any.whl (377 kB)
Collecting tensorflow
Downloading tensorflow-2.2.0-cp36-cp36m-manylinux2010_x86_64.whl (516.2 MB)
Collecting Click==7.0
Downloading Click-7.0-py2.py3-none-any.whl (81 kB)
Collecting Flask==1.1.1
Downloading Flask-1.1.1-py2.py3-none-any.whl (94 kB)
Collecting gunicorn==19.9.0
Downloading gunicorn-19.9.0-py2.py3-none-any.whl (112 kB)
Collecting itsdangerous==1.1.0
Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting Jinja2==2.10.1
Downloading Jinja2-2.10.1-py2.py3-none-any.whl (124 kB)
Collecting MarkupSafe==1.1.1
Downloading MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (27 kB)
Collecting Werkzeug==0.15.6
Downloading Werkzeug-0.15.6-py2.py3-none-any.whl (328 kB)
Collecting pytz>=2017.2
Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
Collecting python-dateutil>=2.6.1
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting joblib>=0.11
Downloading joblib-0.15.1-py3-none-any.whl (298 kB)
Collecting scipy>=0.19.1
Downloading scipy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (26.1 MB)
Collecting threadpoolctl>=2.0.0
Downloading threadpoolctl-2.1.0-py3-none-any.whl (12 kB)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1
Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.2.0-cp36-cp36m-manylinux1_x86_64.whl (88 kB)
Collecting cycler>=0.10
Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting six>=1.9.0
Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting h5py
Downloading h5py-2.10.0-cp36-cp36m-manylinux1_x86_64.whl (2.9 MB)
Collecting keras-preprocessing>=1.0.5
Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)
Collecting keras-applications>=1.0.6
Downloading Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
Collecting pyyaml
Downloading PyYAML-5.3.1.tar.gz (269 kB)
Collecting gast==0.3.3
Downloading gast-0.3.3-py2.py3-none-any.whl (9.7 kB)
Collecting tensorboard<2.3.0,>=2.2.0
Downloading tensorboard-2.2.2-py3-none-any.whl (3.0 MB)
Collecting absl-py>=0.7.0
Downloading absl-py-0.9.0.tar.gz (104 kB)
Collecting grpcio>=1.8.6
Downloading grpcio-1.29.0-cp36-cp36m-manylinux2010_x86_64.whl (3.0 MB)
Collecting protobuf>=3.8.0
Downloading protobuf-3.12.2-cp36-cp36m-manylinux1_x86_64.whl (1.3 MB)
Collecting tensorflow-estimator<2.3.0,>=2.2.0
Downloading tensorflow_estimator-2.2.0-py2.py3-none-any.whl (454 kB)
Collecting google-pasta>=0.1.8
Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
Collecting astunparse==1.6.3
Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Collecting opt-einsum>=2.3.2
Downloading opt_einsum-3.2.1-py3-none-any.whl (63 kB)
Collecting wrapt>=1.11.1
Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting termcolor>=1.1.0
Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting setuptools>=41.0.0
Downloading setuptools-47.1.1-py3-none-any.whl (583 kB)
Collecting requests<3,>=2.21.0
Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting tensorboard-plugin-wit>=1.6.0
Downloading tensorboard_plugin_wit-1.6.0.post3-py3-none-any.whl (777 kB)
Collecting google-auth-oauthlib<0.5,>=0.4.1
Downloading google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting markdown>=2.6.8
Downloading Markdown-3.2.2-py3-none-any.whl (88 kB)
Collecting google-auth<2,>=1.6.3
Downloading google_auth-1.16.0-py2.py3-none-any.whl (90 kB)
Collecting certifi>=2017.4.17
Downloading certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
Collecting idna<3,>=2.5
Downloading idna-2.9-py2.py3-none-any.whl (58 kB)
Collecting chardet<4,>=3.0.2
Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Downloading urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
Collecting requests-oauthlib>=0.7.0
Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting importlib-metadata; python_version < “3.8”
Downloading importlib_metadata-1.6.0-py2.py3-none-any.whl (30 kB)
Collecting cachetools<5.0,>=2.0.0
Downloading cachetools-4.1.0-py3-none-any.whl (10 kB)
Collecting rsa<4.1,>=3.1.4
Downloading rsa-4.0-py2.py3-none-any.whl (38 kB)
Collecting pyasn1-modules>=0.2.1
Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting oauthlib>=3.0.0
Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
Collecting zipp>=0.5
Downloading zipp-3.1.0-py3-none-any.whl (4.9 kB)
Collecting pyasn1>=0.1.3
Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Building wheels for collected packages: pyyaml, absl-py, wrapt, termcolor
Building wheel for pyyaml (setup.py): started
Building wheel for pyyaml (setup.py): finished with status ‘done’
Created wheel for pyyaml: filename=PyYAML-5.3.1-cp36-cp36m-linux_x86_64.whl size=402158 sha256=448cca3f468160398126ad299a6b128510d1c8e2f68677c4c9ae3bde7071a323
Stored in directory: /tmp/pip-ephem-wheel-cache-6jq4dnmg/wheels/e5/9d/ad/2ee53cf262cba1ffd8afe1487eef788ea3f260b7e6232a80fc
Building wheel for absl-py (setup.py): started
Building wheel for absl-py (setup.py): finished with status ‘done’
Created wheel for absl-py: filename=absl_py-0.9.0-py3-none-any.whl size=121931 sha256=5ee9ad55bbe48b09acabce57031fe3ae76eba7f5903aa6c87725de8edf5aa9fc
Stored in directory: /tmp/pip-ephem-wheel-cache-6jq4dnmg/wheels/c3/af/84/3962a6af7b4ab336e951b7877dcfb758cf94548bb1771e0679
Building wheel for wrapt (setup.py): started
Building wheel for wrapt (setup.py): finished with status ‘done’
Created wheel for wrapt: filename=wrapt-1.12.1-cp36-cp36m-linux_x86_64.whl size=69735 sha256=dfda93a18e6d89d97658f1001be16a53dd8d833e5027f5fb71f740d64584f5fc
Stored in directory: /tmp/pip-ephem-wheel-cache-6jq4dnmg/wheels/32/42/7f/23cae9ff6ef66798d00dc5d659088e57dbba01566f6c60db63
Building wheel for termcolor (setup.py): started
Building wheel for termcolor (setup.py): finished with status ‘done’
Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=25452a296baa8e7d0fed141cef07c3268eca283b7791e9b97e24abd2032aa86a
Stored in directory: /tmp/pip-ephem-wheel-cache-6jq4dnmg/wheels/93/2a/eb/e58dbcbc963549ee4f065ff80a59f274cc7210b6eab962acdc
Successfully built pyyaml absl-py wrapt termcolor
Installing collected packages: numpy, pytz, six, python-dateutil, pandas, joblib, scipy, threadpoolctl, scikit-learn, pyparsing, kiwisolver, cycler, matplotlib, h5py, keras-preprocessing, keras-applications, pyyaml, keras, gast, absl-py, setuptools, grpcio, certifi, idna, chardet, urllib3, requests, tensorboard-plugin-wit, cachetools, pyasn1, rsa, pyasn1-modules, google-auth, oauthlib, requests-oauthlib, google-auth-oauthlib, zipp, importlib-metadata, markdown, Werkzeug, protobuf, tensorboard, tensorflow-estimator, google-pasta, astunparse, opt-einsum, wrapt, termcolor, tensorflow, Click, itsdangerous, MarkupSafe, Jinja2, Flask, gunicorn
Attempting uninstall: setuptools
Found existing installation: setuptools 39.0.1
Uninstalling setuptools-39.0.1:
Successfully uninstalled setuptools-39.0.1
Successfully installed Click-7.0 Flask-1.1.1 Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-0.15.6 absl-py-0.9.0 astunparse-1.6.3 cachetools-4.1.0 certifi-2020.4.5.1 chardet-3.0.4 cycler-0.10.0 gast-0.3.3 google-auth-1.16.0 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.29.0 gunicorn-19.9.0 h5py-2.10.0 idna-2.9 importlib-metadata-1.6.0 itsdangerous-1.1.0 joblib-0.15.1 keras-2.3.1 keras-applications-1.0.8 keras-preprocessing-1.1.2 kiwisolver-1.2.0 markdown-3.2.2 matplotlib-3.2.1 numpy-1.18.5 oauthlib-3.1.0 opt-einsum-3.2.1 pandas-1.0.4 protobuf-3.12.2 pyasn1-0.4.8 pyasn1-modules-0.2.8 pyparsing-2.4.7 python-dateutil-2.8.1 pytz-2020.1 pyyaml-5.3.1 requests-2.23.0 requests-oauthlib-1.3.0 rsa-4.0 scikit-learn-0.23.1 scipy-1.4.1 setuptools-47.1.1 six-1.15.0 tensorboard-2.2.2 tensorboard-plugin-wit-1.6.0.post3 tensorflow-2.2.0 tensorflow-estimator-2.2.0 termcolor-1.1.0 threadpoolctl-2.1.0 urllib3-1.25.9 wrapt-1.12.1 zipp-3.1.0
-----> Discovering process types
Procfile declares types -> web
-----> Compressing…
! Compiled slug size: 656.4M is too large (max is 500M).
! See: http://devcenter.heroku.com/articles/slug-size
! Push failed

it exceeded the limit 500 mb.
I have no clue what to do now?
One more clarification needed- what we must write in requirements.txt for this project(asking about extra added libraries please check if its wriiten correct). And do we also need to push the static (that folder of saved images) to git?

code at-(static folder not included)

hey @shinigami,

Its just that you have over exhausted the resources available. As your code and files are exceeding the resource limit , so you can only either try to optimize your code and remove the unnecessary things or you have to pay for extra memory space required. Have a look at github student educational pack , it provides various paid resources for free , and i guess there is a heroku plan also. Else you can different servers for this.

Requirements.txt is basically a list of all modules which ever do you need to run your code properly. Yeah you have made it right and still if there are any other modules needed in your application you can add them too.

These images would be required if you had to train your model on that server , but as you have pre-trained weights , then i guess you don’t need to upload that static folder. But if you want to use any such image on heroku application for any kind of demonstration or any other thing , then you need to upload it in the static folder.

I hope this might have resolved your doubts.
Thank You and Happy Learning. :slightly_smiling_face:

Thankyou. Also, this tensorflow alone is of 516 MB. like inspite of writing tensorflow as a whole in requirements.txt can we import only its specifics which are required in the project? (this will reduce the size if yes pls tell how) and even i checked for student account it gives 512 mb only. could you please tell me an alternative?(free ofc some serives are free for paticular time and then charge, i dont want such)

No , that can’t be done. You have to install whole tensorflow library to make things work properly. Else it will be giving runtime errors that this file is missing , cannot import this module etc.

@shinigami , so you are left with only one option to buy some server resources. You can have a look at google cloud and AWS , they are a bit cheaper then others . Also , github student pack provides you with 5 or 50 $ in digital Ocean . You can try that , it is also good.

But , you have to buy resources to make application work .

Thank You and Happy Coding :slightly_smiling_face:.