VenkataSaiNeha commited on
Commit
6ea0491
1 Parent(s): e54fe7e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from gradio import Interface, Image, Label
3
+ import tensorflow as tf
4
+ # Load your TensorFlow model
5
+ model = tf.keras.models.load_model("mango_leaf_disease_model.h5")
6
+
7
+ # Define your class names if needed
8
+ class_names = ['Anthracnose', 'Bacterial Canker', 'Cutting Weevil', 'Die Back', 'Gall Midge','Healthy','Powdery Mildew','Sooty Mould']
9
+
10
+
11
+ # Function to make predictions
12
+ def classify_image(image):
13
+ # Preprocess the image
14
+ img = tf.image.resize(image, (224, 224))
15
+ img = tf.expand_dims(img, 0) # Add batch dimension
16
+ # Make prediction
17
+ prediction = model.predict(img)
18
+ predicted_class = class_names[prediction.argmax()]
19
+ return predicted_class
20
+
21
+ # Gradio interface
22
+ image = Image() # Remove the `shape` argument
23
+ label = Label()
24
+
25
+ # Create interface
26
+ interface = Interface(classify_image, image, label,
27
+ title="Mango leaf disease detection",
28
+ description="Upload an image of a leaf.").launch()