Harshith Reddy commited on
Commit
3aaab6c
·
1 Parent(s): 99d60d1

Fix Gradio Slider.update() API - use gr.update() instead

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -782,13 +782,15 @@ def create_interface():
782
 
783
  def update_slice_slider(file):
784
  if file is None:
785
- return gr.Slider.update(maximum=100, value=50)
786
  try:
787
- volume = nib.load(file.name).get_fdata()
 
788
  max_slices = volume.shape[-1] if len(volume.shape) == 3 else volume.shape[2]
789
- return gr.Slider.update(maximum=max_slices - 1, value=max_slices // 2)
790
- except:
791
- return gr.Slider.update(maximum=100, value=50)
 
792
 
793
  nifti_input.change(
794
  fn=update_slice_slider,
 
782
 
783
  def update_slice_slider(file):
784
  if file is None:
785
+ return gr.update(maximum=100, value=50)
786
  try:
787
+ file_path = file.name if hasattr(file, 'name') else str(file)
788
+ volume = nib.load(file_path).get_fdata()
789
  max_slices = volume.shape[-1] if len(volume.shape) == 3 else volume.shape[2]
790
+ return gr.update(maximum=max_slices - 1, value=max_slices // 2)
791
+ except Exception as e:
792
+ print(f"Error updating slice slider: {e}")
793
+ return gr.update(maximum=100, value=50)
794
 
795
  nifti_input.change(
796
  fn=update_slice_slider,