Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
|
4 |
-
from skimage import data
|
5 |
from PIL import Image
|
6 |
from torchkeras import plots
|
7 |
from torchkeras.data import get_url_img
|
@@ -13,10 +12,6 @@ from ultralytics.yolo.data import utils
|
|
13 |
|
14 |
model = YOLO('yolov8n.pt')
|
15 |
|
16 |
-
#prepare example images
|
17 |
-
Image.fromarray(data.coffee()).save('coffee.jpeg')
|
18 |
-
Image.fromarray(data.astronaut()).save('people.jpeg')
|
19 |
-
Image.fromarray(data.cat()).save('cat.jpeg')
|
20 |
|
21 |
#load class_names
|
22 |
yaml_path = str(Path(ultralytics.__file__).parent/'datasets/coco128.yaml')
|
@@ -34,19 +29,16 @@ def detect(img):
|
|
34 |
return vis
|
35 |
|
36 |
with gr.Blocks() as demo:
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
files = ['people.jpeg','coffee.jpeg','cat.jpeg']
|
41 |
-
drop_down = gr.Dropdown(choices=files,value=files[0])
|
42 |
button = gr.Button("执行检测",variant="primary")
|
43 |
|
44 |
-
|
45 |
gr.Markdown("## 预测输出")
|
46 |
out_img = gr.Image(type='pil')
|
47 |
|
48 |
button.click(detect,
|
49 |
-
inputs=
|
50 |
outputs=out_img)
|
51 |
|
52 |
with gr.Tab("输入图片链接"):
|
@@ -72,16 +64,7 @@ with gr.Blocks() as demo:
|
|
72 |
inputs=input_img,
|
73 |
outputs=out_img)
|
74 |
|
75 |
-
|
76 |
-
input_img = gr.Image(source='webcam',type='pil')
|
77 |
-
button = gr.Button("执行检测",variant="primary")
|
78 |
-
|
79 |
-
gr.Markdown("## 预测输出")
|
80 |
-
out_img = gr.Image(type='pil')
|
81 |
-
|
82 |
-
button.click(detect,
|
83 |
-
inputs=input_img,
|
84 |
-
outputs=out_img)
|
85 |
|
86 |
gr.close_all()
|
87 |
demo.queue()
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
|
|
|
4 |
from PIL import Image
|
5 |
from torchkeras import plots
|
6 |
from torchkeras.data import get_url_img
|
|
|
12 |
|
13 |
model = YOLO('yolov8n.pt')
|
14 |
|
|
|
|
|
|
|
|
|
15 |
|
16 |
#load class_names
|
17 |
yaml_path = str(Path(ultralytics.__file__).parent/'datasets/coco128.yaml')
|
|
|
29 |
return vis
|
30 |
|
31 |
with gr.Blocks() as demo:
|
32 |
+
|
33 |
+
with gr.Tab("捕捉摄像头喔"):
|
34 |
+
input_img = gr.Image(source='webcam',type='pil')
|
|
|
|
|
35 |
button = gr.Button("执行检测",variant="primary")
|
36 |
|
|
|
37 |
gr.Markdown("## 预测输出")
|
38 |
out_img = gr.Image(type='pil')
|
39 |
|
40 |
button.click(detect,
|
41 |
+
inputs=input_img,
|
42 |
outputs=out_img)
|
43 |
|
44 |
with gr.Tab("输入图片链接"):
|
|
|
64 |
inputs=input_img,
|
65 |
outputs=out_img)
|
66 |
|
67 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
gr.close_all()
|
70 |
demo.queue()
|