maregu2023 commited on
Commit
3846302
·
1 Parent(s): ae8a3d6

Fix: Correct type annotation causing Gradio schema serialization bug

Browse files
Files changed (2) hide show
  1. app.py +4 -0
  2. seg_app/ui/gradio_app.py +2 -2
app.py CHANGED
@@ -80,11 +80,14 @@ if __name__ == "__main__":
80
 
81
  if os.environ.get("SPACE_ID"):
82
  # Running in HF Spaces - use settings for public hosting
 
 
83
  logger.info("Starting seg_app on Hugging Face Spaces...")
84
  demo.launch(
85
  server_name="0.0.0.0",
86
  server_port=7860,
87
  share=False,
 
88
  )
89
  else:
90
  # Local development
@@ -93,4 +96,5 @@ if __name__ == "__main__":
93
  server_name="127.0.0.1",
94
  server_port=7869,
95
  share=False,
 
96
  )
 
80
 
81
  if os.environ.get("SPACE_ID"):
82
  # Running in HF Spaces - use settings for public hosting
83
+ # show_api=False disables the /api endpoint which has a bug in Gradio 5.9.1
84
+ # that crashes on complex type schemas (TypeError: 'bool' is not iterable)
85
  logger.info("Starting seg_app on Hugging Face Spaces...")
86
  demo.launch(
87
  server_name="0.0.0.0",
88
  server_port=7860,
89
  share=False,
90
+ show_api=False,
91
  )
92
  else:
93
  # Local development
 
96
  server_name="127.0.0.1",
97
  server_port=7869,
98
  share=False,
99
+ show_api=False,
100
  )
seg_app/ui/gradio_app.py CHANGED
@@ -170,14 +170,14 @@ def update_coronal_slice(index: int) -> Optional[Image.Image]:
170
 
171
  def run_segmentation_task(
172
  model_id: str,
173
- ) -> Tuple[Image.Image, Image.Image, Image.Image, Dict[str, Any]]:
174
  """Run segmentation on the current volume and display results.
175
 
176
  Args:
177
  model_id: ID of the model to use for segmentation
178
 
179
  Returns:
180
- Tuple of (axial_overlay, sagittal_overlay, coronal_overlay, metrics)
181
  """
182
  global _current_mask
183
 
 
170
 
171
  def run_segmentation_task(
172
  model_id: str,
173
+ ) -> Tuple[Optional[Image.Image], Optional[Image.Image], Optional[Image.Image], str]:
174
  """Run segmentation on the current volume and display results.
175
 
176
  Args:
177
  model_id: ID of the model to use for segmentation
178
 
179
  Returns:
180
+ Tuple of (axial_overlay, sagittal_overlay, coronal_overlay, metrics_str)
181
  """
182
  global _current_mask
183