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

8
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
import gradio as gr
@ -41,6 +41,10 @@ def yolov10_inference_video(video, model_path, image_size, conf_threshold):
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():
with gr.Blocks():
with gr.Row():
@ -126,7 +130,7 @@ def app():
0.25,
],
],
fn=yolov10_inference,
fn=yolov10_inference_for_examples,
inputs=[
image,
model_id,