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