lllyasviel commited on
Commit
13d1420
·
1 Parent(s): 818f705
Files changed (3) hide show
  1. modules/core.py +3 -1
  2. modules/default_pipeline.py +3 -2
  3. webui.py +8 -2
modules/core.py CHANGED
@@ -163,7 +163,7 @@ def ksampler(model, positive, negative, latent, seed=None, steps=30, cfg=7.0, sa
163
  def ksampler_with_refiner(model, positive, negative, refiner, refiner_positive, refiner_negative, latent,
164
  seed=None, steps=30, refiner_switch_step=20, cfg=7.0, sampler_name='dpmpp_2m_sde_gpu',
165
  scheduler='karras', denoise=1.0, disable_noise=False, start_step=None, last_step=None,
166
- force_full_denoise=False):
167
  # SCHEDULERS = ["normal", "karras", "exponential", "simple", "ddim_uniform"]
168
  # SAMPLERS = ["euler", "euler_ancestral", "heun", "dpm_2", "dpm_2_ancestral",
169
  # "lms", "dpm_fast", "dpm_adaptive", "dpmpp_2s_ancestral", "dpmpp_sde", "dpmpp_sde_gpu",
@@ -189,6 +189,8 @@ def ksampler_with_refiner(model, positive, negative, refiner, refiner_positive,
189
  pbar = comfy.utils.ProgressBar(steps)
190
 
191
  def callback(step, x0, x, total_steps):
 
 
192
  if previewer and step % 3 == 0:
193
  previewer.preview(x0, step, total_steps)
194
  pbar.update_absolute(step + 1, total_steps, None)
 
163
  def ksampler_with_refiner(model, positive, negative, refiner, refiner_positive, refiner_negative, latent,
164
  seed=None, steps=30, refiner_switch_step=20, cfg=7.0, sampler_name='dpmpp_2m_sde_gpu',
165
  scheduler='karras', denoise=1.0, disable_noise=False, start_step=None, last_step=None,
166
+ force_full_denoise=False, callback_function=None):
167
  # SCHEDULERS = ["normal", "karras", "exponential", "simple", "ddim_uniform"]
168
  # SAMPLERS = ["euler", "euler_ancestral", "heun", "dpm_2", "dpm_2_ancestral",
169
  # "lms", "dpm_fast", "dpm_adaptive", "dpmpp_2s_ancestral", "dpmpp_sde", "dpmpp_sde_gpu",
 
189
  pbar = comfy.utils.ProgressBar(steps)
190
 
191
  def callback(step, x0, x, total_steps):
192
+ if callback_function is not None:
193
+ callback_function(step, x0, x, total_steps)
194
  if previewer and step % 3 == 0:
195
  previewer.preview(x0, step, total_steps)
196
  pbar.update_absolute(step + 1, total_steps, None)
modules/default_pipeline.py CHANGED
@@ -17,7 +17,7 @@ xl_refiner = core.load_model(xl_refiner_filename)
17
 
18
 
19
  @torch.no_grad()
20
- def process(positive_prompt, negative_prompt, steps, switch, width, height, image_seed):
21
  positive_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=positive_prompt)
22
  negative_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=negative_prompt)
23
 
@@ -36,7 +36,8 @@ def process(positive_prompt, negative_prompt, steps, switch, width, height, imag
36
  refiner_switch_step=switch,
37
  latent=empty_latent,
38
  steps=steps, start_step=0, last_step=steps, disable_noise=False, force_full_denoise=True,
39
- seed=image_seed
 
40
  )
41
 
42
  decoded_latent = core.decode_vae(vae=xl_refiner.vae, latent_image=sampled_latent)
 
17
 
18
 
19
  @torch.no_grad()
20
+ def process(positive_prompt, negative_prompt, steps, switch, width, height, image_seed, callback):
21
  positive_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=positive_prompt)
22
  negative_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=negative_prompt)
23
 
 
36
  refiner_switch_step=switch,
37
  latent=empty_latent,
38
  steps=steps, start_step=0, last_step=steps, disable_noise=False, force_full_denoise=True,
39
+ seed=image_seed,
40
+ callback_function=callback
41
  )
42
 
43
  decoded_latent = core.decode_vae(vae=xl_refiner.vae, latent_image=sampled_latent)
webui.py CHANGED
@@ -25,8 +25,14 @@ def generate_clicked(prompt, negative_prompt, style_selction, performance_selcti
25
  if not isinstance(seed, int) or seed < 0 or seed > 65535:
26
  seed = random.randint(1, 65535)
27
 
28
- for i in progress.tqdm(range(image_number)):
29
- imgs = process(p_txt, n_txt, steps, switch, width, height, seed)
 
 
 
 
 
 
30
  seed += 1
31
  results += imgs
32
 
 
25
  if not isinstance(seed, int) or seed < 0 or seed > 65535:
26
  seed = random.randint(1, 65535)
27
 
28
+ all_steps = steps * image_number
29
+
30
+ def callback(step, x0, x, total_steps):
31
+ done_steps = i * image_number + step
32
+ progress(float(done_steps) / float(all_steps), f'Step {step}/{total_steps} in the {i}-th Sampling')
33
+
34
+ for i in range(image_number):
35
+ imgs = process(p_txt, n_txt, steps, switch, width, height, seed, callback=callback)
36
  seed += 1
37
  results += imgs
38