samwell Claude commited on
Commit
227178d
Β·
1 Parent(s): 4167f4b

feat: Side-by-side layout with chat and visualization

Browse files

Changed 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]>

Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -271,19 +271,26 @@ with gr.Blocks() as demo:
271
  info="Assistant Mode: Direct answers | Tutor Mode: Socratic guidance through questions"
272
  )
273
 
274
- # Use type="messages" for newer Gradio versions on HF Spaces
275
- try:
276
- chatbot = gr.Chatbot(type="messages")
277
- except TypeError:
278
- # Fallback for older Gradio versions
279
- chatbot = gr.Chatbot()
280
- viz_output = gr.Image(label="Visualization (Grounding/Segmentation)", visible=True)
281
-
282
- msg = gr.MultimodalTextbox(
283
- label="Message",
284
- placeholder="Upload an X-ray image (JPG, PNG, DICOM) and ask a question...",
285
- file_types=["image", ".dcm", ".dicom", ".DCM", ".DICOM"]
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