feat: Side-by-side layout with chat and visualization
Browse filesChanged from stacked to side-by-side layout for better UX:
Before (stacked):
- Chat messages on top
- Visualization below
- Had to scroll to see both
After (side-by-side):
- Chat on left (2/3 width)
- Visualization on right (1/3 width)
- See both simultaneously
- Fixed height of 600px for both
Layout structure:
βββββββββββββββββββββββββββ¬βββββββββββββββ
β Chat Messages β Visualizationβ
β (scale=2) β (scale=1) β
β β β
β Message Input β β
βββββββββββββββββββββββββββ΄βββββββββββββββ
Benefits:
- Better use of screen space
- View segmentation/grounding while chatting
- More professional clinical interface
- Similar to PACS viewer layouts
Co-Authored-By: Claude <[email protected]>
|
@@ -271,19 +271,26 @@ with gr.Blocks() as demo:
|
|
| 271 |
info="Assistant Mode: Direct answers | Tutor Mode: Socratic guidance through questions"
|
| 272 |
)
|
| 273 |
|
| 274 |
-
#
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
|
| 288 |
def respond(message, chat_history, mode_selection):
|
| 289 |
# Convert mode selection to internal mode string
|
|
|
|
| 271 |
info="Assistant Mode: Direct answers | Tutor Mode: Socratic guidance through questions"
|
| 272 |
)
|
| 273 |
|
| 274 |
+
# Side-by-side layout: Chat on left, Visualization on right
|
| 275 |
+
with gr.Row():
|
| 276 |
+
# Left column: Chat interface
|
| 277 |
+
with gr.Column(scale=2):
|
| 278 |
+
# Use type="messages" for newer Gradio versions on HF Spaces
|
| 279 |
+
try:
|
| 280 |
+
chatbot = gr.Chatbot(type="messages", height=600)
|
| 281 |
+
except TypeError:
|
| 282 |
+
# Fallback for older Gradio versions
|
| 283 |
+
chatbot = gr.Chatbot(height=600)
|
| 284 |
+
|
| 285 |
+
msg = gr.MultimodalTextbox(
|
| 286 |
+
label="Message",
|
| 287 |
+
placeholder="Upload an X-ray image (JPG, PNG, DICOM) and ask a question...",
|
| 288 |
+
file_types=["image", ".dcm", ".dicom", ".DCM", ".DICOM"]
|
| 289 |
+
)
|
| 290 |
+
|
| 291 |
+
# Right column: Visualization
|
| 292 |
+
with gr.Column(scale=1):
|
| 293 |
+
viz_output = gr.Image(label="Visualization (Grounding/Segmentation)", height=600)
|
| 294 |
|
| 295 |
def respond(message, chat_history, mode_selection):
|
| 296 |
# Convert mode selection to internal mode string
|