Reputation: 27
I have a flask app, and i am using tensorflow and keras to load the model that i am going to use.Below is a code snippet
from tensorflow.keras.models import Model , load_model
from keras.preprocessing import image
# Flask utils
from flask import Flask, redirect, url_for, request, render_template
from werkzeug.utils import secure_filename
from gevent.pywsgi import WSGIServer
app = Flask(__name__)
Model= load_model('models/model_pro1.h5')
so i then deploy the flask app on heroku and it builds successfully, but when i check the logs i see that i get an error image for the heroku logs I have tried installing both tensorflow and keras with out a particular version in the requirements.txt file but not getting it solved. I want to know what i am not doing right, and thanks in advance. I am using code from this github repo github repo
Upvotes: 1
Views: 3382
Reputation: 41
I'll give an instance of saving a model and then loading it
import tensorflow as tf
from tensorflow import keras
model.save(./abc.h5 # saves in h5 format)
model.save(./defg)#defg is a folder having pb file
To load the saved model,
new_model = tf.keras.models.load_model('./abc.h5') #for loading h5 model
or
new_model = tf.keras.models.load_model('defg/) # for loading pb model
I think your syntax of load_model is the mistake you committed
Upvotes: 1
Reputation: 589
Beginning with Python 3, all strings are unicode by default. So i think your dev environment, where you built and trained the models is running python2 while the heroku env has python3.
Upvotes: 0