import tensorflow as tf from tf.keras.models import load_model model = load_model('myModel.hdf5') import gradio as gr def classify(inp): 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)