andreped commited on
Commit
5c17f85
·
1 Parent(s): ca94437

Placed slider under 2D viewer box

Browse files
Files changed (1) hide show
  1. neukit/gui.py +12 -16
neukit/gui.py CHANGED
@@ -51,7 +51,7 @@ class WebUI:
51
  def upload_file(self, file):
52
  return file.name
53
 
54
- def load_mesh(self, mesh_file_name):
55
  path = mesh_file_name.name
56
  run_model(path, model_path=self.cwd + "resources/models/", task=self.class_names[self.class_name], name=self.result_names[self.class_name])
57
  nifti_to_glb("prediction.nii.gz")
@@ -80,14 +80,10 @@ class WebUI:
80
  }
81
  """
82
  with gr.Blocks(css=css) as demo:
83
-
84
  with gr.Row():
85
-
86
  file_output = gr.File(file_count="single", elem_id="upload") # elem_id="upload"
87
  file_output.upload(self.upload_file, file_output, file_output)
88
 
89
- # with gr.Column():
90
-
91
  model_selector = gr.Dropdown(
92
  list(self.class_names.keys()),
93
  label="Task",
@@ -103,7 +99,7 @@ class WebUI:
103
 
104
  run_btn = gr.Button("Run analysis").style(full_width=False, size="lg")
105
  run_btn.click(
106
- fn=lambda x: self.load_mesh(x),
107
  inputs=file_output,
108
  outputs=self.volume_renderer,
109
  )
@@ -119,20 +115,20 @@ class WebUI:
119
 
120
  with gr.Row():
121
  with gr.Box():
122
- image_boxes = []
123
- for i in range(self.nb_slider_items):
124
- visibility = True if i == 1 else False
125
- t = gr.AnnotatedImage(visible=visibility, elem_id="model-2d")\
126
- .style(color_map={self.class_name: "#ffae00"}, height=512, width=512)
127
- image_boxes.append(t)
 
128
 
129
- self.slider.change(self.get_img_pred_pair, self.slider, image_boxes)
 
 
130
 
131
  with gr.Box():
132
  self.volume_renderer.render()
133
-
134
- with gr.Row():
135
- self.slider.render()
136
 
137
  # sharing app publicly -> share=True: https://gradio.app/sharing-your-app/
138
  # inference times > 60 seconds -> need queue(): https://github.com/tloen/alpaca-lora/issues/60#issuecomment-1510006062
 
51
  def upload_file(self, file):
52
  return file.name
53
 
54
+ def process(self, mesh_file_name):
55
  path = mesh_file_name.name
56
  run_model(path, model_path=self.cwd + "resources/models/", task=self.class_names[self.class_name], name=self.result_names[self.class_name])
57
  nifti_to_glb("prediction.nii.gz")
 
80
  }
81
  """
82
  with gr.Blocks(css=css) as demo:
 
83
  with gr.Row():
 
84
  file_output = gr.File(file_count="single", elem_id="upload") # elem_id="upload"
85
  file_output.upload(self.upload_file, file_output, file_output)
86
 
 
 
87
  model_selector = gr.Dropdown(
88
  list(self.class_names.keys()),
89
  label="Task",
 
99
 
100
  run_btn = gr.Button("Run analysis").style(full_width=False, size="lg")
101
  run_btn.click(
102
+ fn=lambda x: self.process(x),
103
  inputs=file_output,
104
  outputs=self.volume_renderer,
105
  )
 
115
 
116
  with gr.Row():
117
  with gr.Box():
118
+ with gr.Column():
119
+ image_boxes = []
120
+ for i in range(self.nb_slider_items):
121
+ visibility = True if i == 1 else False
122
+ t = gr.AnnotatedImage(visible=visibility, elem_id="model-2d")\
123
+ .style(color_map={self.class_name: "#ffae00"}, height=512, width=512)
124
+ image_boxes.append(t)
125
 
126
+ self.slider.input(self.get_img_pred_pair, self.slider, image_boxes)
127
+
128
+ self.slider.render()
129
 
130
  with gr.Box():
131
  self.volume_renderer.render()
 
 
 
132
 
133
  # sharing app publicly -> share=True: https://gradio.app/sharing-your-app/
134
  # inference times > 60 seconds -> need queue(): https://github.com/tloen/alpaca-lora/issues/60#issuecomment-1510006062