Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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