Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,7 @@ from ultralytics.yolo.data import utils
|
|
12 |
|
13 |
model = YOLO('yolov8n.pt')
|
14 |
|
|
|
15 |
#load class_names
|
16 |
yaml_path = str(Path(ultralytics.__file__).parent/'datasets/coco128.yaml')
|
17 |
class_names = utils.yaml_load(yaml_path)['names']
|
@@ -27,33 +28,35 @@ def detect(img):
|
|
27 |
vis = img
|
28 |
return vis
|
29 |
|
30 |
-
with gr.
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
button.click(detect,
|
42 |
-
inputs=input_img,
|
43 |
-
outputs=out_img)
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
model = YOLO('yolov8n.pt')
|
14 |
|
15 |
+
|
16 |
#load class_names
|
17 |
yaml_path = str(Path(ultralytics.__file__).parent/'datasets/coco128.yaml')
|
18 |
class_names = utils.yaml_load(yaml_path)['names']
|
|
|
28 |
vis = img
|
29 |
return vis
|
30 |
|
31 |
+
with gr.Blocks() as demo:
|
32 |
+
|
33 |
+
header_html = gr.Html("<h1>foodServed, drinkServed, person, V0.0.1</h1>")
|
34 |
+
|
35 |
+
with gr.Tab("Upload"):
|
36 |
+
header_html.display()
|
37 |
+
input_img = gr.Image(type='pil')
|
38 |
+
button = gr.Button("Detect",variant="primary")
|
39 |
+
|
40 |
+
gr.Markdown("## Output")
|
41 |
+
out_img = gr.Image(type='pil')
|
|
|
|
|
|
|
42 |
|
43 |
+
button.click(detect,
|
44 |
+
inputs=input_img,
|
45 |
+
outputs=out_img)
|
46 |
+
|
47 |
+
with gr.Tab("Url"):
|
48 |
+
header_html.display()
|
49 |
+
default_url = 'https://t7.baidu.com/it/u=3601447414,1764260638&fm=193&f=GIF'
|
50 |
+
url = gr.Textbox(value=default_url)
|
51 |
+
button = gr.Button("Detect",variant="primary")
|
52 |
+
|
53 |
+
gr.Markdown("## Output")
|
54 |
+
out_img = gr.Image(type='pil')
|
55 |
+
|
56 |
+
button.click(detect,
|
57 |
+
inputs=url,
|
58 |
+
outputs=out_img)
|
59 |
+
|
60 |
+
gr.close_all()
|
61 |
+
demo.queue()
|
62 |
+
demo.launch()
|