fix gr.Examples output type mismatch by adding separate function for examples

This commit is contained in:
Sencer Yücel 2024-05-31 08:35:38 +03:00
parent f87b08feee
commit 34af6d27fa

10
app.py
View File

@ -1,4 +1,4 @@
# Ackownledgement: https://huggingface.co/spaces/kadirnar/Yolov10/blob/main/app.py # Acknowledgement: https://huggingface.co/spaces/kadirnar/Yolov10/blob/main/app.py
# Thanks to @kadirnar # Thanks to @kadirnar
import gradio as gr import gradio as gr
@ -41,6 +41,10 @@ def yolov10_inference_video(video, model_path, image_size, conf_threshold):
return None, output_video_path return None, output_video_path
def yolov10_inference_for_examples(image, model_path, image_size, conf_threshold):
annotated_image, _ = yolov10_inference(image, model_path, image_size, conf_threshold)
return annotated_image
def app(): def app():
with gr.Blocks(): with gr.Blocks():
with gr.Row(): with gr.Row():
@ -126,7 +130,7 @@ def app():
0.25, 0.25,
], ],
], ],
fn=yolov10_inference, fn=yolov10_inference_for_examples,
inputs=[ inputs=[
image, image,
model_id, model_id,
@ -149,4 +153,4 @@ with gradio_app:
with gr.Column(): with gr.Column():
app() app()
gradio_app.launch(debug=True) gradio_app.launch(debug=True)