Skip to content

Commit

Permalink
Merge pull request #29 from andreped/improved-demo-ui
Browse files Browse the repository at this point in the history
2D and 3D viewer of equal height + 2D viewer center aligned
  • Loading branch information
andreped committed Jun 2, 2023
2 parents cb41cf7 + acb6152 commit caa148e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions demo/src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def __init__(self, model_name:str = None, class_name:str = None, cwd:str = None)
self.volume_renderer = gr.Model3D(
clear_color=[0.0, 0.0, 0.0, 0.0],
label="3D Model",
visible=True
visible=True,
elem_id="model-3d",
).style(height=512)

def combine_ct_and_seg(self, img, pred):
Expand All @@ -47,9 +48,18 @@ def get_img_pred_pair(self, k):
return out

def run(self):
with gr.Blocks() as demo:
css="""
#model-3d {
height: 512px;
}
#model-2d {
height: 512px;
margin: auto;
}
"""
with gr.Blocks(css=css) as demo:

with gr.Row().style(equal_height=True):
with gr.Row():
file_output = gr.File(
file_types=[".nii", ".nii.nz"],
file_count="single"
Expand All @@ -63,7 +73,7 @@ def run(self):
outputs=self.volume_renderer
)

with gr.Row().style(equal_height=True):
with gr.Row():
gr.Examples(
examples=[self.cwd + "test-volume.nii"],
inputs=file_output,
Expand All @@ -72,12 +82,12 @@ def run(self):
cache_examples=True,
)

with gr.Row().style(equal_height=True):
with gr.Row():
with gr.Box():
image_boxes = []
for i in range(self.nb_slider_items):
visibility = True if i == 1 else False
t = gr.AnnotatedImage(visible=visibility)\
t = gr.AnnotatedImage(visible=visibility, elem_id="model-2d")\
.style(color_map={self.class_name: "#ffae00"}, height=512, width=512)
image_boxes.append(t)

Expand Down

0 comments on commit caa148e

Please sign in to comment.