0

2022-02-25T07:37:49.000000+00:00 app[api]: Build started by user mrmazores@tip.edu.ph 2022-02-25T07:38:18.384694+00:00 app[api]: Release v4 created by user mrmazores@tip.edu.ph 2022-02-25T07:38:18.384694+00:00 app[api]: Deploy d1afaaa1 by user mrmazores@tip.edu.ph 2022-02-25T07:38:18.723319+00:00 heroku[worker.1]: State changed from crashed to starting 2022-02-25T07:38:24.743621+00:00 heroku[worker.1]: Starting process with command python server.ipynb 2022-02-25T07:38:25.365530+00:00 heroku[worker.1]: State changed from starting to up 2022-02-25T07:38:25.695999+00:00 heroku[worker.1]: Process exited with status 0 2022-02-25T07:38:25.753899+00:00 heroku[worker.1]: State changed from up to crashed 2022-02-25T07:38:29.000000+00:00 app[api]: Build succeeded

from flask import Flask, request, jsonify
import tensorflow as tf
import os
import numpy as np
import json

model = tf.keras.models.load_model("densenet201v1.hdf5")

label = ('door_knock',
         'doorbell',
         'emergency_alarm ',
         'kettle_clicking',
         'kettle_running', 
         'kettle_whistling',
         'microwave_beeping' ,
         'microwave_running' ,
         'telephone',
         'wakeup_alarm',
         'washing_machine',
         'water_running')

def print_prediction (x, db):
    predicted_vector=model.predict(x)
    predicted_proba=np.argmax(predicted_vector,axis=1)
    if label[predicted_proba[0]] == label[0] or label[predicted_proba[0]] == label[1] or label[predicted_proba[0]] == label[2] or label[predicted_proba[0]] == label[9]:
        #print(db)
        return label[predicted_proba[0]]
        #print(label[predicted_proba[0]])
        #print(predicted_vector[0][predicted_proba[0]])
        #print(predicted_vector[0])
    elif predicted_vector[0][predicted_proba[0]] >= .50 and db > -30.0:
        #print(db)
        return label[predicted_proba[0]]
        #print(predicted_vector[0][predicted_proba[0]])
        #print(label[predicted_proba[0]])
        #print(predicted_vector[0])

app = Flask(__name__)

@app.route("/", methods=["POST"])
def index():
    #get feature
    feature = np.array(request.json["feature"])
    dB = np.array(request.json["dB"])
    #make prediction
    prediction = print_prediction(feature, dB)
    #send in json format
    return jsonify({"prediction": prediction})

if __name__ == "__main__":
    app.run(debug=False)

When I open the app I get:

2022-02-25T16:19:38.978905+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=home--ear.herokuapp.com request_id=4fa7e23f-7e43-46ec-99f1-cc5c8644f5e7 fwd="136.158.57.136" dyno= connect= service= status=503 bytes= protocol=https
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
SparraWoW
  • 1
  • 1
  • 1
    Welcome to Stack Overflow. [Please don't post screenshots of text](https://meta.stackoverflow.com/a/285557/354577). They can't be searched or copied, or even consumed by users of adaptive technologies like screen readers. Instead, paste the code as text directly into your question. If you select it and click the `{}` button or Ctrl+K the code block will be indented by four spaces, which will cause it to be rendered as code. – ChrisGPT was on strike Feb 25 '22 at 10:35
  • There are at least two issues here: (a) You are trying to run `python server.ipynb` but notebooks are not executable by Python that way. What is in that file? Does it need to be a notebook? (b) Assuming you _do_ need Jupyter, it is not included in your `requirements.txt` and will therefore not be available at runtime. – ChrisGPT was on strike Feb 25 '22 at 10:38
  • Thanks for answering. I edited the question for the code. Somehow i try to debug it but not working – SparraWoW Feb 25 '22 at 16:10
  • It is ok to change it manually to .py extension? – SparraWoW Feb 25 '22 at 16:12
  • Additionally, i use tensorflow in my code but i didnt include tensorflow in my requirements.txt because it takes size and giving the error slugsize exceed 500 MiB – SparraWoW Feb 25 '22 at 16:14
  • Feel free to visit my github https://github.com/SparraWoooW/HomeEAR – SparraWoW Feb 25 '22 at 16:24
  • "It is ok to change it manually to .py extension?"—assuming that's actually a Jupyter Notebook and not a regular Python file, no. You'll have to extract the code, e.g. see [Get only the code out of Jupyter Notebook](https://stackoverflow.com/q/54350254/354577) – ChrisGPT was on strike Feb 25 '22 at 17:47
  • "i use tensorflow in my code but i didnt include tensorflow in my requirements.txt because it takes size and giving the error slugsize exceed 500 MiB"—well if you need it at runtime you'll have to declare it as a dependency. See if [Deploy python app to Heroku "Slug Size too large"](https://stackoverflow.com/q/61062303/354577) helps with that. – ChrisGPT was on strike Feb 25 '22 at 17:49
  • I got new error "ImportError: cannot import name 'json' from 'itsdangerous' (/app/.heroku/python/lib/python3.9/site-packages/itsdangerous/__init__.py) ". But it is first time that it reads what inside my sever file. Thank you very much – SparraWoW Feb 25 '22 at 19:54
  • I solve the new error. It runs! thank you very much!! – SparraWoW Feb 25 '22 at 20:08

0 Answers0