Spaces:
Runtime error
Runtime error
Update app.py
Browse files2 unmodified lines3456678991011121413141516171918192021222324262526272822 unmodified lines5152535554555658575859604 unmodified lines65666769686970712 unmodified lines# Import YOLOv9import yolov9
# Define function to perform prediction with YOLOv9 model# Define function to perform prediction with YOLO modeldef predict_image(image, model_path, image_size, conf_threshold, iou_threshold):
# Load YOLO model model = YOLO(model_path) # Perform inference with YOLO model results = model(image, size=image_size, conf=conf_threshold, iou=iou_threshold) results = model.predict(image, size=image_size, conf=conf_threshold, iou=iou_threshold) # Render the output output_image = results.render() return output_image[0] return output_image
# Define Gradio interfacedef app(): with gr.Blocks(): with gr.Row(): with gr.Column(): img_path = gr.Image(type="filepath", label="Image") img_path = gr.Image(type="file", label="Image") model_path = gr.Dropdown( label="Model", choices=[22 unmodified lines step=0.1, value=0.5, ) yolov9_infer = gr.Button(value="Submit") yolov9_infer = gr.Button(label="Submit")
with gr.Column(): output_numpy = gr.Image(type="numpy", label="Output") output_image = gr.Image(type="numpy", label="Output")
yolov9_infer.click( fn=predict_image,4 unmodified lines conf_threshold, iou_threshold, ], outputs=[output_numpy], outputs=[output_image], )
gradio_app = gr.Blocks()app.py+7-8