Spaces:
Sleeping
Sleeping
File size: 729 Bytes
c34536f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
import tensorflow as tf
IMG_SIZE = (120, 120)
# load keras model
model_path = 'banana_model.h5'
model = tf.keras.models.load_model(model_path)
categories = ('ripe', 'unripe')
def classify_image(img):
img_array_expanded_dims = img.reshape((-1, 120, 120, 3))
prediction = model.predict(img_array_expanded_dims)
prediction_prob = float(tf.nn.sigmoid(prediction))
probs = [1-prediction_prob, prediction_prob]
return dict(zip(categories, probs))
gr_image = gr.inputs.Image(shape=IMG_SIZE)
label = gr.outputs.Label()
examples = ['ripe.jpeg', 'green.jpeg', 'unknown.jpeg']
iface = gr.Interface(fn=classify_image, inputs=gr_image, outputs=label, examples=examples)
iface.launch(inline=False) |