ilass commited on
Commit
62cce40
·
1 Parent(s): 49b84ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -29
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.Interface(fn=lambda x: x) as iface:
31
- gr.Markdown("# Willkommen zu meiner App!") # Dieser Text wird oberhalb der Tabs angezeigt.
32
-
33
- with gr.Blocks() as demo:
34
- with gr.Tab("Upload"):
35
- input_img = gr.Image(type='pil')
36
- button = gr.Button("Detect",variant="primary")
37
-
38
- gr.Markdown("## Output")
39
- out_img = gr.Image(type='pil')
40
-
41
- button.click(detect,
42
- inputs=input_img,
43
- outputs=out_img)
44
 
45
- with gr.Tab("Url"):
46
- default_url = 'https://t7.baidu.com/it/u=3601447414,1764260638&fm=193&f=GIF'
47
- url = gr.Textbox(value=default_url)
48
- button = gr.Button("Detect",variant="primary")
49
-
50
- gr.Markdown("## Output")
51
- out_img = gr.Image(type='pil')
52
-
53
- button.click(detect,
54
- inputs=url,
55
- outputs=out_img)
56
-
57
- demo.launch()
58
-
59
- gr.close_all()
 
 
 
 
 
 
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()