We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
here`s working code:
import flask import tensorflow as tf from tensorflow import keras from keras.utils import CustomObjectScope from keras.models import load_model from tensorflow.keras.utils import img_to_array from PIL import Image import numpy as np import io from tensorflow.keras.models import load_model #curl -X POST -F [email protected] 'http://localhost:5000/infer' #to predict app = flask.Flask(__name__) #with CustomObjectScope({'relu6': keras.applications.mobilenet.relu6}): with CustomObjectScope({'relu6': keras.layers.ReLU(6.),'DepthwiseConv2D': keras.layers.DepthwiseConv2D}): #model = load_model('ADD_H5_MODEL_PATH') model = load_model("model.h5") def preprocess(image): image = image.resize((224, 224)) image = img_to_array(image) image = np.expand_dims(image, axis=0) return image @app.route('/infer', methods=['POST']) def infer(): file = flask.request.files['image'].read() image = Image.open(io.BytesIO(file)) image = preprocess(image) predictions = model.predict(image) max_index = np.argmax(predictions) # We know the labels from the model we trained previously if max_index == 0: return "Cat" else: return "Dog" if __name__ == "__main__": app.run() #app.run(host="0.0.0.0") # for access from lan
The text was updated successfully, but these errors were encountered:
Appreciate sharing this @zoldaten , we'll start to incorporate this soon.
Sorry, something went wrong.
No branches or pull requests
here`s working code:
The text was updated successfully, but these errors were encountered: