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