Spaces:
Runtime error
Runtime error
File size: 598 Bytes
e5cc9a3 6f98250 e5cc9a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import tensorflow as tf
from tf.keras.models import load_model
model = load_model('myModel.hdf5')
import gradio as gr
from gradio import inputs
def classify(img):
img_array = tf.keras.utils.img_to_array(img)
img_array = tf.expand_dims(img_array, 0) # Create a batch
predictions = model.predict(img_array)
score = tf.nn.softmax(predictions[0])
confidences = {class_names[i]: float(score[i]) for i in range(5)}
return confidences
gr.Interface(fn=classify,
inputs=gr.Image(shape=(180, 180)),
outputs=gr.Label(num_top_classes=5)).launch(debug=True)
|