hysts HF staff commited on
Commit
8f4581c
1 Parent(s): d60da15
Files changed (2) hide show
  1. app.py +22 -23
  2. style.css +7 -1
app.py CHANGED
@@ -22,6 +22,13 @@ import numpy as np
22
 
23
  from model import Model
24
 
 
 
 
 
 
 
 
25
  DEFAULT_MODEL_TYPE = 'detection'
26
  DEFAULT_MODEL_NAMES = {
27
  'detection': 'YOLOX-l',
@@ -80,16 +87,12 @@ def set_example_image(example: list) -> dict:
80
 
81
  def main():
82
  args = parse_args()
83
-
84
  extract_tar()
85
  model = Model(DEFAULT_MODEL_NAME, args.device)
86
 
87
  with gr.Blocks(theme=args.theme, css='style.css') as demo:
88
- gr.Markdown('''<h1 id="title">MMDetection</h1>
89
-
90
- This is an unofficial demo for [https://github.com/open-mmlab/mmdetection](https://github.com/open-mmlab/mmdetection).
91
- <center><img id="overview" alt="overview" src="https://user-images.githubusercontent.com/12907710/137271636-56ba1cd2-b110-4812-8221-b4c120320aa9.png" /></center>
92
- ''')
93
 
94
  with gr.Row():
95
  with gr.Column():
@@ -127,27 +130,23 @@ This is an unofficial demo for [https://github.com/open-mmlab/mmdetection](https
127
  samples=[[path.as_posix()]
128
  for path in paths])
129
 
130
- gr.Markdown(
131
- '<center><img src="https://visitor-badge.glitch.me/badge?page_id=hysts.mmdetection" alt="visitor badge"/></center>'
132
- )
133
 
134
  input_image.change(fn=update_input_image,
135
- inputs=[input_image],
136
- outputs=[input_image])
137
 
138
  model_type.change(fn=update_model_name,
139
- inputs=[model_type],
140
- outputs=[model_name])
141
  model_type.change(fn=update_visualization_score_threshold,
142
- inputs=[model_type],
143
- outputs=[visualization_score_threshold])
144
  model_type.change(fn=update_redraw_button,
145
- inputs=[model_type],
146
- outputs=[redraw_button])
147
 
148
- model_name.change(fn=model.set_model,
149
- inputs=[model_name],
150
- outputs=None)
151
  run_button.click(fn=model.detect_and_visualize,
152
  inputs=[
153
  input_image,
@@ -163,10 +162,10 @@ This is an unofficial demo for [https://github.com/open-mmlab/mmdetection](https
163
  prediction_results,
164
  visualization_score_threshold,
165
  ],
166
- outputs=[visualization])
167
  example_images.click(fn=set_example_image,
168
- inputs=[example_images],
169
- outputs=[input_image])
170
 
171
  demo.launch(
172
  enable_queue=args.enable_queue,
 
22
 
23
  from model import Model
24
 
25
+ TITLE = '# MMDetection'
26
+ DESCRIPTION = '''
27
+ This is an unofficial demo for [https://github.com/open-mmlab/mmdetection](https://github.com/open-mmlab/mmdetection).
28
+ <img id="overview" alt="overview" src="https://user-images.githubusercontent.com/12907710/137271636-56ba1cd2-b110-4812-8221-b4c120320aa9.png" />
29
+ '''
30
+ FOOTER = '<img id="visitor-badge" src="https://visitor-badge.glitch.me/badge?page_id=hysts.mmdetection" alt="visitor badge" />'
31
+
32
  DEFAULT_MODEL_TYPE = 'detection'
33
  DEFAULT_MODEL_NAMES = {
34
  'detection': 'YOLOX-l',
 
87
 
88
  def main():
89
  args = parse_args()
 
90
  extract_tar()
91
  model = Model(DEFAULT_MODEL_NAME, args.device)
92
 
93
  with gr.Blocks(theme=args.theme, css='style.css') as demo:
94
+ gr.Markdown(TITLE)
95
+ gr.Markdown(DESCRIPTION)
 
 
 
96
 
97
  with gr.Row():
98
  with gr.Column():
 
130
  samples=[[path.as_posix()]
131
  for path in paths])
132
 
133
+ gr.Markdown(FOOTER)
 
 
134
 
135
  input_image.change(fn=update_input_image,
136
+ inputs=input_image,
137
+ outputs=input_image)
138
 
139
  model_type.change(fn=update_model_name,
140
+ inputs=model_type,
141
+ outputs=model_name)
142
  model_type.change(fn=update_visualization_score_threshold,
143
+ inputs=model_type,
144
+ outputs=visualization_score_threshold)
145
  model_type.change(fn=update_redraw_button,
146
+ inputs=model_type,
147
+ outputs=redraw_button)
148
 
149
+ model_name.change(fn=model.set_model, inputs=model_name, outputs=None)
 
 
150
  run_button.click(fn=model.detect_and_visualize,
151
  inputs=[
152
  input_image,
 
162
  prediction_results,
163
  visualization_score_threshold,
164
  ],
165
+ outputs=visualization)
166
  example_images.click(fn=set_example_image,
167
+ inputs=example_images,
168
+ outputs=input_image)
169
 
170
  demo.launch(
171
  enable_queue=args.enable_queue,
style.css CHANGED
@@ -1,7 +1,13 @@
1
- h1#title {
2
  text-align: center;
3
  }
4
  img#overview {
 
 
5
  max-width: 1000px;
6
  max-height: 600px;
7
  }
 
 
 
 
 
1
+ h1 {
2
  text-align: center;
3
  }
4
  img#overview {
5
+ display: block;
6
+ margin: auto;
7
  max-width: 1000px;
8
  max-height: 600px;
9
  }
10
+ img#visitor-badge {
11
+ display: block;
12
+ margin: auto;
13
+ }