File size: 729 Bytes
8d9f842
 
 
 
57f4ecb
8d9f842
57f4ecb
 
 
 
 
8d9f842
57f4ecb
e9671ed
57f4ecb
 
 
 
 
 
 
 
 
 
 
 
 
 
e9671ed
0f3261d
57f4ecb
8d9f842
57f4ecb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
from ultralytics import YOLO

# 加载模型
model = YOLO('NailongKiller.yolo11n.pt')

def predict(img):
    # 运行推理
    results = model.predict(img)
    # 返回第一个结果的绘制图像
    return results[0].plot()

# 创建 Gradio 演示
demo = gr.Interface(
    predict,
    inputs=[
        gr.Image(label="输入图片")
    ],
    outputs=[
        gr.Image(label="检测结果", type="numpy")
    ],
    title="🐉 奶龙杀手 (NailongKiller)",
    description="上传图片来检测奶龙 | Upload an image to detect Nailong",
    examples=[
        ["example1.jpg"],
        ["example2.jpg"]
    ],
    cache_examples=True
)

# 启动应用
if __name__ == "__main__":
    demo.launch()