from gradio import Interface, Image, Label import tensorflow as tf # Load your TensorFlow model model = tf.keras.models.load_model("mangoleaf.h5") # Define your class names if needed class_names = ['Anthracnose', 'Bacterial Canker', 'Cutting Weevil', 'Die Back', 'Gall Midge','Healthy','Powdery Mildew','Sooty Mould'] # Function to make predictions def classify_image(image): # Preprocess the image img = tf.image.resize(image, (224, 224)) img = tf.expand_dims(img, 0) # Add batch dimension # Make prediction prediction = model.predict(img) predicted_class = class_names[prediction.argmax()] return predicted_class # Gradio interface image = Image() # Remove the `shape` argument label = Label() # Create interface interface = Interface(classify_image, image, label, title="Mango leaf disease detection", description="Upload an image of a leaf.").launch()