import torch from ultralytics import YOLO import gradio as gr model = YOLO("best0709.pt") # 或者是從 hf_hub_download 取得 def detect(image): results = model(image) return results[0].plot() # 回傳帶框圖像 iface = gr.Interface(fn=detect, inputs="image", outputs="image") iface.launch(show_api=True)