BiliSakura commited on
Commit
08247fe
·
verified ·
1 Parent(s): eb47665

Fix scheduler dropdown: include checkpoint in choices before load

Browse files
Files changed (2) hide show
  1. app.py +6 -10
  2. model_loader.py +3 -3
app.py CHANGED
@@ -111,19 +111,15 @@ def _scheduler_config(profile, pipe=None):
111
  interactive=False,
112
  info="Uses the checkpoint scheduler (custom, not swappable until loaded)",
113
  )
114
- if pipe is None:
115
- choices = scheduler_choices_for_profile(profile)
116
- return gr.update(
117
- choices=choices,
118
- value="checkpoint",
119
- interactive=not uses_native_scheduler(profile),
120
- info="Defaults to checkpoint scheduler after Load model; optional built-in swap",
121
- )
122
  return gr.update(
123
  choices=choices,
124
  value=default,
125
  interactive=not uses_native_scheduler(profile),
126
- info="Checkpoint scheduler by default; pick another built-in diffusers scheduler to swap",
 
 
 
 
127
  )
128
 
129
 
@@ -349,7 +345,7 @@ def generate(
349
  def build_demo() -> gr.Blocks:
350
  g_start, g_end = _interval_defaults(DEFAULT_PROFILE)
351
  extras = DEFAULT_PROFILE.extra_call_kwargs
352
- default_scheduler_choices = scheduler_choices_for_profile(DEFAULT_PROFILE)
353
  default_scheduler_value = "checkpoint"
354
 
355
  with gr.Blocks(title="BiliSakura Visual Generation Models") as demo:
 
111
  interactive=False,
112
  info="Uses the checkpoint scheduler (custom, not swappable until loaded)",
113
  )
 
 
 
 
 
 
 
 
114
  return gr.update(
115
  choices=choices,
116
  value=default,
117
  interactive=not uses_native_scheduler(profile),
118
+ info=(
119
+ "Checkpoint scheduler by default; pick another built-in diffusers scheduler to swap"
120
+ if pipe is not None
121
+ else "Defaults to checkpoint scheduler after Load model; optional built-in swap"
122
+ ),
123
  )
124
 
125
 
 
345
  def build_demo() -> gr.Blocks:
346
  g_start, g_end = _interval_defaults(DEFAULT_PROFILE)
347
  extras = DEFAULT_PROFILE.extra_call_kwargs
348
+ default_scheduler_choices = ["checkpoint", *scheduler_choices_for_profile(DEFAULT_PROFILE)]
349
  default_scheduler_value = "checkpoint"
350
 
351
  with gr.Blocks(title="BiliSakura Visual Generation Models") as demo:
model_loader.py CHANGED
@@ -170,15 +170,15 @@ def scheduler_options_for_profile(profile: ModelProfile, pipe: DiffusionPipeline
170
  return [name], name
171
  return ["checkpoint"], "checkpoint"
172
 
 
173
  if pipe is not None:
174
  loaded = current_scheduler_name(pipe)
175
- choices = scheduler_choices_for_profile(profile)
176
  if loaded not in choices:
177
  choices = [loaded, *choices]
178
  return choices, loaded
179
 
180
- choices = scheduler_choices_for_profile(profile)
181
- return choices, "checkpoint"
182
 
183
 
184
  def swap_scheduler(pipe: DiffusionPipeline, scheduler_name: str, profile: ModelProfile) -> None:
 
170
  return [name], name
171
  return ["checkpoint"], "checkpoint"
172
 
173
+ swappable = scheduler_choices_for_profile(profile)
174
  if pipe is not None:
175
  loaded = current_scheduler_name(pipe)
176
+ choices = list(swappable)
177
  if loaded not in choices:
178
  choices = [loaded, *choices]
179
  return choices, loaded
180
 
181
+ return ["checkpoint", *swappable], "checkpoint"
 
182
 
183
 
184
  def swap_scheduler(pipe: DiffusionPipeline, scheduler_name: str, profile: ModelProfile) -> None: