Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,31 +67,35 @@ def analyse(img, plant_type):
|
|
67 |
|
68 |
return result
|
69 |
|
70 |
-
#
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
)
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
return result
|
69 |
|
70 |
+
# Build the Gradio Blocks interface
|
71 |
+
with gr.Blocks() as demo:
|
72 |
+
gr.Markdown("## Plant Disease Detection")
|
73 |
+
gr.Markdown("Upload an image of a plant leaf and select the plant type to detect diseases.")
|
74 |
+
|
75 |
+
with gr.Row():
|
76 |
+
with gr.Column():
|
77 |
+
input_image = gr.Image(label="Upload Image", type="numpy")
|
78 |
+
plant_type = gr.Radio(
|
79 |
+
["Apple", "Blueberry", "Cherry", "Corn", "Grape", "Orange", "Peach",
|
80 |
+
"Pepper", "Potato", "Raspberry", "Soybean", "Squash", "Strawberry", "Tomato"],
|
81 |
+
label="Plant Type"
|
82 |
+
)
|
83 |
+
submit = gr.Button("Analyze")
|
84 |
+
|
85 |
+
with gr.Column():
|
86 |
+
result_json = gr.JSON(label="Analysis Result")
|
87 |
+
|
88 |
+
# Example images section
|
89 |
+
gr.Examples(
|
90 |
+
examples=[os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))],
|
91 |
+
inputs=[input_image],
|
92 |
+
label="Examples",
|
93 |
+
cache_examples=False,
|
94 |
+
examples_per_page=8
|
95 |
+
)
|
96 |
+
|
97 |
+
# Define interaction
|
98 |
+
submit.click(fn=analyse, inputs=[input_image, plant_type], outputs=result_json)
|
99 |
+
|
100 |
+
# Launch the application
|
101 |
+
demo.launch(share=True, show_error=True)
|