Dynamically change maximum value of Slider after UI launch

I have developed a simple app with an image viewer, that enables to scroll through a collection of images and render one-at-a-time using a Slider.

The collection of images is something the user can upload by uploading a 3D volume which I will post-process into a list of 2D images.

The problem is that after the user has uploaded their volume, which could be of arbitrary depth, meaning that the number of images in the collection is arbitrary, I see that there is no simple method to update the maximum value of the slider after upload.

I have used the gradio.AnnotatedImage, gradio.Slider, and gradio.FileUpload widgets which are contained inside a gradio.Blocks namespace.

I have tried updating the maximum value of the Slider, but it does not update the rendered Slider. Any suggestions?

The app is deployed on HF spaces:

1 Like