Spaces:
Running
on
Zero
Running
on
Zero
Migrate to ZeroGPU and update requirements for compatibility
Browse files
app.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
from ultralytics import YOLO
|
3 |
-
from fastapi import FastAPI
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
6 |
-
import io
|
7 |
import torch
|
8 |
import spaces
|
9 |
|
@@ -23,25 +22,15 @@ def predict(img):
|
|
23 |
|
24 |
# Gradio 界面
|
25 |
demo = gr.Interface(
|
26 |
-
predict,
|
27 |
-
inputs=
|
28 |
-
|
29 |
-
],
|
30 |
-
outputs=[
|
31 |
-
gr.Image(label="检测结果", type="numpy")
|
32 |
-
],
|
33 |
title="🐉 奶龙杀手 (NailongKiller)",
|
34 |
description="上传图片来检测奶龙 | Upload an image to detect Nailong",
|
35 |
-
examples=[
|
36 |
-
["example1.jpg"]
|
37 |
-
],
|
38 |
cache_examples=True
|
39 |
)
|
40 |
|
41 |
-
# 挂载 Gradio 到 FastAPI
|
42 |
-
app = gr.mount_gradio_app(app, demo, path="/")
|
43 |
-
|
44 |
# 启动应用
|
45 |
if __name__ == "__main__":
|
46 |
-
|
47 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
1 |
import gradio as gr
|
2 |
from ultralytics import YOLO
|
3 |
+
from fastapi import FastAPI
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
|
|
6 |
import torch
|
7 |
import spaces
|
8 |
|
|
|
22 |
|
23 |
# Gradio 界面
|
24 |
demo = gr.Interface(
|
25 |
+
fn=predict,
|
26 |
+
inputs=gr.Image(label="输入图片"),
|
27 |
+
outputs=gr.Image(label="检测结果", type="numpy"),
|
|
|
|
|
|
|
|
|
28 |
title="🐉 奶龙杀手 (NailongKiller)",
|
29 |
description="上传图片来检测奶龙 | Upload an image to detect Nailong",
|
30 |
+
examples=[["example1.jpg"]],
|
|
|
|
|
31 |
cache_examples=True
|
32 |
)
|
33 |
|
|
|
|
|
|
|
34 |
# 启动应用
|
35 |
if __name__ == "__main__":
|
36 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|