andreped commited on
Commit
acb6152
1 Parent(s): be86d91

2D and 3D viewer of equal height + 2D viewer center aligned

Browse files
Files changed (1) hide show
  1. demo/src/gui.py +16 -6
demo/src/gui.py CHANGED
@@ -22,7 +22,8 @@ class WebUI:
22
  self.volume_renderer = gr.Model3D(
23
  clear_color=[0.0, 0.0, 0.0, 0.0],
24
  label="3D Model",
25
- visible=True
 
26
  ).style(height=512)
27
 
28
  def combine_ct_and_seg(self, img, pred):
@@ -47,9 +48,18 @@ class WebUI:
47
  return out
48
 
49
  def run(self):
50
- with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
51
 
52
- with gr.Row().style(equal_height=True):
53
  file_output = gr.File(
54
  file_types=[".nii", ".nii.nz"],
55
  file_count="single"
@@ -63,7 +73,7 @@ class WebUI:
63
  outputs=self.volume_renderer
64
  )
65
 
66
- with gr.Row().style(equal_height=True):
67
  gr.Examples(
68
  examples=[self.cwd + "test-volume.nii"],
69
  inputs=file_output,
@@ -72,12 +82,12 @@ class WebUI:
72
  cache_examples=True,
73
  )
74
 
75
- with gr.Row().style(equal_height=True):
76
  with gr.Box():
77
  image_boxes = []
78
  for i in range(self.nb_slider_items):
79
  visibility = True if i == 1 else False
80
- t = gr.AnnotatedImage(visible=visibility)\
81
  .style(color_map={self.class_name: "#ffae00"}, height=512, width=512)
82
  image_boxes.append(t)
83
 
 
22
  self.volume_renderer = gr.Model3D(
23
  clear_color=[0.0, 0.0, 0.0, 0.0],
24
  label="3D Model",
25
+ visible=True,
26
+ elem_id="model-3d",
27
  ).style(height=512)
28
 
29
  def combine_ct_and_seg(self, img, pred):
 
48
  return out
49
 
50
  def run(self):
51
+ css="""
52
+ #model-3d {
53
+ height: 512px;
54
+ }
55
+ #model-2d {
56
+ height: 512px;
57
+ margin: auto;
58
+ }
59
+ """
60
+ with gr.Blocks(css=css) as demo:
61
 
62
+ with gr.Row():
63
  file_output = gr.File(
64
  file_types=[".nii", ".nii.nz"],
65
  file_count="single"
 
73
  outputs=self.volume_renderer
74
  )
75
 
76
+ with gr.Row():
77
  gr.Examples(
78
  examples=[self.cwd + "test-volume.nii"],
79
  inputs=file_output,
 
82
  cache_examples=True,
83
  )
84
 
85
+ with gr.Row():
86
  with gr.Box():
87
  image_boxes = []
88
  for i in range(self.nb_slider_items):
89
  visibility = True if i == 1 else False
90
+ t = gr.AnnotatedImage(visible=visibility, elem_id="model-2d")\
91
  .style(color_map={self.class_name: "#ffae00"}, height=512, width=512)
92
  image_boxes.append(t)
93