bhanusAI commited on
Commit
509133e
·
verified ·
1 Parent(s): b70330f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -28
app.py CHANGED
@@ -67,31 +67,35 @@ def analyse(img, plant_type):
67
 
68
  return result
69
 
70
- # Create Gradio interface
71
- input_image = gr.Image(type="numpy")
72
- plant_type = gr.Radio(["Apple", "Blueberry", "Cherry", "Corn", "Grape", "Orange", "Peach",
73
- "Pepper", "Potato", "Raspberry", "Soybean", "Squash", "Strawberry", "Tomato"])
74
-
75
-
76
- # Add examples component
77
- examples = gr.Examples(
78
- examples=[
79
- os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
80
- ],
81
- inputs=[input_image],
82
- label="Examples",
83
- cache_examples=False,
84
- examples_per_page=16
85
- )
86
-
87
- demo = gr.Interface(
88
- fn=analyse,
89
- inputs=[input_image, plant_type],
90
- examples,
91
- outputs=gr.JSON(),
92
- title="Plant Disease Detection",
93
- description="Upload an image of a plant leaf or use one of the example images below. Select the type of plant and the model will analyze it for diseases."
94
- )
95
-
96
- # Launch the interface
97
- demo.launch(share=True, show_error=True)
 
 
 
 
 
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)