andreped commited on
Commit
7c7ec80
·
1 Parent(s): 1b2ea5d

Improved UI

Browse files
Files changed (1) hide show
  1. demo/src/gui.py +22 -28
demo/src/gui.py CHANGED
@@ -2,6 +2,7 @@ import os
2
 
3
  import gradio as gr
4
 
 
5
  from .inference import run_model
6
  from .logger import flush_logs
7
  from .logger import read_logs
@@ -107,34 +108,39 @@ class WebUI:
107
  return gr.update(visible=state), state
108
 
109
  def run(self):
110
- css = """
111
- #model-3d {
112
- height: 512px;
113
- }
114
- #model-2d {
115
- height: 512px;
116
- margin: auto;
117
- }
118
- #upload {
119
- height: 160px;
120
- }
121
- """
122
  with gr.Blocks(css=css) as demo:
123
  with gr.Row():
124
  with gr.Column(visible=True, scale=0.2) as sidebar_left:
125
  # gr.Markdown("SideBar Left")
126
  logs = gr.Textbox(
 
127
  label="Logs",
128
  info="Verbose from inference will be displayed below.",
129
- max_lines=16,
 
130
  autoscroll=True,
131
  elem_id="logs",
132
  show_copy_button=True,
 
 
133
  )
134
  demo.load(read_logs, None, logs, every=1)
135
 
136
  with gr.Column():
137
  with gr.Row():
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  file_output = gr.File(
139
  file_count="single", elem_id="upload"
140
  )
@@ -155,9 +161,9 @@ class WebUI:
155
  outputs=None,
156
  )
157
 
158
- with gr.Column():
159
- run_btn = gr.Button("Run analysis").style(
160
- full_width=False, size="lg"
161
  )
162
  run_btn.click(
163
  fn=lambda x: self.process(x),
@@ -165,18 +171,6 @@ class WebUI:
165
  outputs=self.volume_renderer,
166
  )
167
 
168
- sidebar_state = gr.State(True)
169
-
170
- btn_toggle_sidebar = gr.Button("Toggle Sidebar")
171
- btn_toggle_sidebar.click(
172
- self.toggle_sidebar,
173
- [sidebar_state],
174
- [sidebar_left, sidebar_state],
175
- )
176
-
177
- btn_clear_logs = gr.Button("Clear logs")
178
- btn_clear_logs.click(flush_logs, [], [])
179
-
180
  with gr.Row():
181
  gr.Examples(
182
  examples=[
 
2
 
3
  import gradio as gr
4
 
5
+ from .css_style import css
6
  from .inference import run_model
7
  from .logger import flush_logs
8
  from .logger import read_logs
 
108
  return gr.update(visible=state), state
109
 
110
  def run(self):
 
 
 
 
 
 
 
 
 
 
 
 
111
  with gr.Blocks(css=css) as demo:
112
  with gr.Row():
113
  with gr.Column(visible=True, scale=0.2) as sidebar_left:
114
  # gr.Markdown("SideBar Left")
115
  logs = gr.Textbox(
116
+ placeholder="\n" * 16,
117
  label="Logs",
118
  info="Verbose from inference will be displayed below.",
119
+ lines=38,
120
+ max_lines=38,
121
  autoscroll=True,
122
  elem_id="logs",
123
  show_copy_button=True,
124
+ scroll_to_output=False,
125
+ container=True,
126
  )
127
  demo.load(read_logs, None, logs, every=1)
128
 
129
  with gr.Column():
130
  with gr.Row():
131
+ with gr.Column(scale=0.2, min_width=150):
132
+ sidebar_state = gr.State(True)
133
+
134
+ btn_toggle_sidebar = gr.Button("Toggle Sidebar", elem_id="toggle-button")
135
+ btn_toggle_sidebar.click(
136
+ self.toggle_sidebar,
137
+ [sidebar_state],
138
+ [sidebar_left, sidebar_state],
139
+ )
140
+
141
+ btn_clear_logs = gr.Button("Clear logs", elem_id="logs-button")
142
+ btn_clear_logs.click(flush_logs, [], [])
143
+
144
  file_output = gr.File(
145
  file_count="single", elem_id="upload"
146
  )
 
161
  outputs=None,
162
  )
163
 
164
+ with gr.Column(scale=0.2, min_width=150):
165
+ run_btn = gr.Button("Run analysis", variant="primary", elem_id="run-button").style(
166
+ full_width=False, size="lg",
167
  )
168
  run_btn.click(
169
  fn=lambda x: self.process(x),
 
171
  outputs=self.volume_renderer,
172
  )
173
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  with gr.Row():
175
  gr.Examples(
176
  examples=[