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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -45
app.py CHANGED
@@ -12,7 +12,6 @@ from ultralytics.yolo.data import utils
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,47 +27,33 @@ def detect(img):
28
  vis = img
29
  return vis
30
 
31
- with gr.Blocks() as demo:
32
-
33
-
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
-
46
-
47
- with gr.Tab("Url"):
48
- default_url = 'https://t7.baidu.com/it/u=3601447414,1764260638&fm=193&f=GIF'
49
- url = gr.Textbox(value=default_url)
50
- button = gr.Button("Detect",variant="primary")
51
-
52
- gr.Markdown("## Output")
53
- out_img = gr.Image(type='pil')
54
-
55
- button.click(detect,
56
- inputs=url,
57
- outputs=out_img)
58
-
59
-
60
- # with gr.Tab("Webcam"):
61
- # input_img = gr.Image(source='webcam',type='pil')
62
- # button = gr.Button("Detect",variant="primary")
63
-
64
- # gr.Markdown("## Output")
65
- # out_img = gr.Image(type='pil')
66
-
67
- # button.click(detect,
68
- # inputs=input_img,
69
- # outputs=out_img)
70
-
71
-
72
- gr.close_all()
73
- demo.queue()
74
- demo.launch()
 
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
  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()