Spaces:
Runtime error
Runtime error
File size: 2,125 Bytes
9f8fcff 6626681 9f8fcff d9c2732 85a9e35 d341b67 d9c2732 bd2f9b4 d9c2732 bd2f9b4 c9f3d67 d341b67 9f8fcff bd2f9b4 9f8fcff 6f5ca27 9f8fcff 5aff31f 9f8fcff bb41d73 9f8fcff 430b3cb 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 48 49 50 51 52 |
import gradio as gr
from detection import ObjectDetection
examples = [
['test-images/plant1.jpeg', 0.23],
['test-images/plant2.jpeg', 0.45],
['test-images/plant3.webp', 0.43],
]
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
# Load the YOLOv8s model for plant leaf detection and classification
yolov8_detector = ObjectDetection('Yolov8')
with gr.Blocks(title="Plant Leaf Detection and Classification", theme=gr.themes.Soft()) as interface:
gr.Markdown("# Plant Leaf Detection and Classification🍃")
gr.Markdown("This app uses YOLOv8s, a powerful object detection model, to detect and classify plant leaves. "
"The model can detect various plant leaves and classify them into up to 45 different plant categories, "
"whether the leafs are diseased or healthy.")
gr.Markdown("If you like this app, don't forget to give it a thumbs up on Hugging Face!😊❤️@ www.Foduu.com")
with gr.Row():
with gr.Column():
image = gr.Image(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.6, label="Confidence Threshold", interactive=True)
btn = gr.Button("Detect")
with gr.Row():
with gr.Box():
v8_prediction = gr.Image(shape=(200,200),label="Leaf Detection and Classification") # Display the output image in its original size
btn.click(
get_predictions,
[image, confidence, box_color, text_color],
[v8_prediction]
)
with gr.Row():
gr.Examples(examples=examples, inputs=[image, confidence])
interface.launch()
|