Application Error on Heroku but model successfully deployed

Adarsh Wase

I am trying to deploy a deep learning Flask app on Heroku. It is successfully deployed, but still giving me the Application Error message. I have checked the logs, but didn't find anything. Help me!

Build logs -

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> No Python version was specified. Using the same version as the last build: python-3.9.7
       To use a different version, see:
-----> Requirements file has been changed, clearing cached dependencies
-----> Installing python-3.9.7
-----> Installing pip 21.3.1, setuptools 57.5.0 and wheel 0.37.0
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting Flask==1.1.2
         Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)

Successfully installed Flask-1.1.2 Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-1.0.1 absl-py-0.15.0 astunparse-1.6.3 cachetools-4.2.4 certifi-2021.10.8 charset-normalizer-2.0.7 click-8.0.3 flatbuffers-1.12 gast-0.4.0 google-auth-2.3.3 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.34.1 gunicorn-20.0.4 h5py-3.1.0 idna-3.3 itsdangerous-1.1.0 keras-nightly-2.5.0.dev2021032900 keras-preprocessing-1.1.2 markdown-3.3.4 numpy-1.19.5 oauthlib-3.1.1 opencv-python- opt-einsum-3.3.0 protobuf-3.19.1 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.26.0 requests-oauthlib-1.3.0 rsa-4.7.2 six-1.15.0 tensorboard-2.7.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.0 tensorflow-cpu-2.5.0 tensorflow-estimator-2.5.0 termcolor-1.1.0 tqdm-4.59.0 typing-extensions- urllib3-1.26.7 wrapt-1.12.1
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 439.1M
-----> Launching...
 !     Warning: Your slug size (439 MB) exceeds our soft limit (300 MB) which may affect boot time.
       Released v4 deployed to Heroku

Here is my -

app = Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1

def index():
    return render_template('index.html')

@app.route('/after', methods = ['GET', 'POST'])
def after():

    global model, resnet, vocab, inv_vocab

    img = request.files['file1']'static/file.jpg')

    print("=" * 50)
    print("IMAGE SAVED")

    image = cv2.imread('static/file.jpg')
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    image = cv2.resize(image, (224, 224))
    image = np.reshape(image, (1, 224, 224, 3))

    incept = resnet.predict(image).reshape(1, 2048)

    print("=" * 50)
    print("Predict Features")
    text_in = ['startofseq']
    final = ''
    count = 0
    while tqdm(count < 20):
        count += 1
        encoded = []
        for i in text_in:
        padded = pad_sequences([encoded], maxlen = 36, padding = 'post', truncating = 'post')
        sampled_index = np.argmax(model.predict([incept, padded]))
        sampled_word = inv_vocab[sampled_index]
        if sampled_word != 'endofseq':
            final = final + ' ' + sampled_word
    return render_template('after.html', data = final)

if __name__ == "__main__":

Here is my GitHub repo - LINK

My applications logs:

2021-11-08T06:11:59.657691+00:00 app[web.1]:   File "", line 1, in <module>
2021-11-08T06:11:59.657772+00:00 app[web.1]:     import cv2
2021-11-08T06:11:59.657781+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/cv2/", line 5, in <module>
2021-11-08T06:11:59.657862+00:00 app[web.1]:     from .cv2 import *
2021-11-08T06:11:59.657876+00:00 app[web.1]: ImportError: cannot open shared object file: No such file or directory
2021-11-08T06:11:59.842143+00:00 heroku[web.1]: Process exited with status 1
2021-11-08T06:11:59.906506+00:00 heroku[web.1]: State changed from starting to crashed
2021-11-08T06:12:08.000000+00:00 app[api]: Build succeeded
2021-11-08T06:12:11.971382+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" request_id=bc6b146e-11bb-407e-a861-ba9244a954e3 fwd="" dyno= connect= service= status=503 bytes= protocol=https
2021-11-08T06:12:12.623298+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" request_id=74968483-821f-459c-b317-b7e02e8a5c82 fwd="" dyno= connect= service= status=503 bytes= protocol=https
Adarsh Wase

This error has been solved by changing this line on requirements.txt:




Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


TOP Ranking