orronai commited on
Commit
2ca8c63
·
1 Parent(s): cc6f003

fix: sliders values

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -30,16 +30,19 @@ def seed_everything(seed: int) -> None:
30
  torch.manual_seed(seed)
31
  torch.cuda.manual_seed_all(seed)
32
 
33
- def on_T_steps_change(T_steps: int) -> gr.update:
34
  """
35
- Update the maximum value of the n_max slider based on the T_steps value.
36
 
37
  Args:
38
  T_steps (int): The current value of the T_steps slider.
 
39
  Returns:
40
- gr.update: An update object to modify the n_max slider's maximum value.
41
  """
42
- return gr.update(maximum=T_steps)
 
 
43
 
44
  def on_model_change(model_type: str) -> Tuple[int, int, float]:
45
  if model_type == 'SD3':
@@ -210,7 +213,7 @@ with gr.Blocks(css=css) as demo:
210
  )
211
 
212
  model_type.input(fn=on_model_change, inputs=[model_type], outputs=[T_steps, n_max, eta])
213
- T_steps.change(fn=on_T_steps_change, inputs=[T_steps], outputs=[n_max])
214
 
215
  demo.queue()
216
  demo.launch()
 
30
  torch.manual_seed(seed)
31
  torch.cuda.manual_seed_all(seed)
32
 
33
+ def on_T_steps_change(T_steps: int, n_max: int) -> gr.update:
34
  """
35
+ Update the maximum and value of the n_max slider based on T_steps.
36
 
37
  Args:
38
  T_steps (int): The current value of the T_steps slider.
39
+ n_max (int): The current value of the n_max slider.
40
  Returns:
41
+ gr.update: An update object to modify the n_max slider.
42
  """
43
+ # If n_max > T_steps, clamp it down to T_steps
44
+ new_value = min(n_max, T_steps)
45
+ return gr.update(maximum=T_steps, value=new_value)
46
 
47
  def on_model_change(model_type: str) -> Tuple[int, int, float]:
48
  if model_type == 'SD3':
 
213
  )
214
 
215
  model_type.input(fn=on_model_change, inputs=[model_type], outputs=[T_steps, n_max, eta])
216
+ T_steps.change(fn=on_T_steps_change, inputs=[T_steps, n_max], outputs=[n_max])
217
 
218
  demo.queue()
219
  demo.launch()