Jayanthk2004 commited on
Commit
e2e1ebb
·
verified ·
1 Parent(s): d970825

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # prompt: use this model, https://huggingface.co/liriope/PlantDiseaseDetection, create app.py for implementing this on gradio
2
+
3
+ import gradio as gr
4
+ from transformers import pipeline
5
+
6
+ # Load the pre-trained model
7
+ pipe = pipeline("image-classification", model="liriope/PlantDiseaseDetection")
8
+
9
+ def classify_image(image):
10
+ predictions = pipe(image)
11
+ result = ""
12
+ for pred in predictions:
13
+ label = pred["label"]
14
+ score = pred["score"]
15
+ result += f"{label}: {score:.4f}\n"
16
+ return result
17
+
18
+ iface = gr.Interface(
19
+ fn=classify_image,
20
+ inputs=gr.Image(type="pil"),
21
+ outputs="text",
22
+ title="Plant Disease Classifier",
23
+ description="Upload an image to classify the plant disease.",
24
+ )
25
+
26
+ iface.launch(debug=True)