import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import tensorflow as tf from tensorflow.keras.models import load_model model = load_model('myModel.hdf5') import gradio as gr from gradio import inputs class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips'] 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)