nehulagrawal commited on
Commit
9f8fcff
·
1 Parent(s): 8d642b1

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from detection import ObjectDetection
3
+
4
+ examples = [
5
+ ['test-images/plant1.jpeg', 0.31],
6
+ ['test-images/plant2.jpeg', 0.51],
7
+ ['test-images/plant3.webp', 0.39],
8
+ ]
9
+
10
+ def get_predictions(img, threshold, box_color, text_color):
11
+ v8_results = yolov8_detector.v8_score_frame(img)
12
+ v8_frame = yolov8_detector.plot_bboxes(v8_results, img, float(threshold), box_color, text_color)
13
+ return v8_frame
14
+
15
+ with gr.Blocks(title="Leaf Disease Detection", theme=gr.themes.Monochrome()) as interface:
16
+ gr.Markdown("# Leaf Disease Detection")
17
+ with gr.Row():
18
+ with gr.Column():
19
+ image = gr.Image(shape=(416,416), label="Input Image")
20
+ with gr.Column():
21
+ with gr.Row():
22
+ with gr.Column():
23
+ box_color = gr.ColorPicker(label="Box Color", value="#0000ff")
24
+ with gr.Column():
25
+ text_color = gr.ColorPicker(label="Prediction Color", value="#ff0000")
26
+
27
+ confidence = gr.Slider(maximum=1, step=0.01, value=0.4, label="Confidence Threshold", interactive=True)
28
+ btn = gr.Button("Detect")
29
+
30
+ with gr.Row():
31
+ with gr.Box():
32
+ v8_prediction = gr.Image(shape=(416,416), label="YOLOv8")
33
+
34
+ btn.click(
35
+ get_predictions,
36
+ [image, confidence, box_color, text_color],
37
+ [v8_prediction]
38
+ )
39
+
40
+ with gr.Row():
41
+ gr.Examples(examples=examples, inputs=[image, confidence])
42
+
43
+
44
+ yolov8_detector = ObjectDetection('yolov8')
45
+
46
+ interface.launch()