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