File size: 936 Bytes
6ea0491
 
 
 
c2e4df6
6ea0491
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

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()