lllyasviel commited on
Commit
16e8fe9
·
1 Parent(s): a770fa7
modules/core.py CHANGED
@@ -178,7 +178,6 @@ def ksampler_with_refiner(model, positive, negative, refiner, refiner_positive,
178
  noise_mask = prepare_mask(noise_mask, noise.shape, device)
179
 
180
  comfy.model_management.load_model_gpu(model)
181
- real_model = model.model
182
 
183
  noise = noise.to(device)
184
  latent_image = latent_image.to(device)
@@ -188,8 +187,9 @@ def ksampler_with_refiner(model, positive, negative, refiner, refiner_positive,
188
 
189
  models = load_additional_models(positive, negative, model.model_dtype())
190
 
191
- sampler = KSamplerWithRefiner(real_model, steps=steps, device=device, sampler=sampler_name, scheduler=scheduler,
192
- denoise=denoise, model_options=model.model_options)
 
193
 
194
  samples = sampler.sample(noise, positive_copy, negative_copy, cfg=cfg, latent_image=latent_image,
195
  start_step=start_step, last_step=last_step, force_full_denoise=force_full_denoise,
 
178
  noise_mask = prepare_mask(noise_mask, noise.shape, device)
179
 
180
  comfy.model_management.load_model_gpu(model)
 
181
 
182
  noise = noise.to(device)
183
  latent_image = latent_image.to(device)
 
187
 
188
  models = load_additional_models(positive, negative, model.model_dtype())
189
 
190
+ sampler = KSamplerWithRefiner(model=model.model, refiner_model=refiner.model, steps=steps, device=device,
191
+ sampler=sampler_name, scheduler=scheduler,
192
+ denoise=denoise, model_options=model.model_options)
193
 
194
  samples = sampler.sample(noise, positive_copy, negative_copy, cfg=cfg, latent_image=latent_image,
195
  start_step=start_step, last_step=last_step, force_full_denoise=force_full_denoise,
modules/default_pipeline.py CHANGED
@@ -27,7 +27,7 @@ def process(positive_prompt, negative_prompt, width=1024, height=1024, batch_siz
27
  model=xl_base.unet,
28
  positive=positive_conditions,
29
  negative=negative_conditions,
30
- refiner=xl_refiner,
31
  refiner_positive=positive_conditions_refiner,
32
  refiner_negative=negative_conditions_refiner,
33
  refiner_switch_step=20,
 
27
  model=xl_base.unet,
28
  positive=positive_conditions,
29
  negative=negative_conditions,
30
+ refiner=xl_refiner.unet,
31
  refiner_positive=positive_conditions_refiner,
32
  refiner_negative=negative_conditions_refiner,
33
  refiner_switch_step=20,
modules/samplers_advanced.py CHANGED
@@ -7,15 +7,26 @@ class KSamplerWithRefiner:
7
  "lms", "dpm_fast", "dpm_adaptive", "dpmpp_2s_ancestral", "dpmpp_sde", "dpmpp_sde_gpu",
8
  "dpmpp_2m", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "ddim", "uni_pc", "uni_pc_bh2"]
9
 
10
- def __init__(self, model, steps, device, sampler=None, scheduler=None, denoise=None, model_options={}):
11
  self.model = model
 
 
12
  self.model_denoise = CFGNoisePredictor(self.model)
 
 
13
  if self.model.model_type == model_base.ModelType.V_PREDICTION:
14
  self.model_wrap = CompVisVDenoiser(self.model_denoise, quantize=True)
15
  else:
16
  self.model_wrap = k_diffusion_external.CompVisDenoiser(self.model_denoise, quantize=True)
17
 
 
 
 
 
 
18
  self.model_k = KSamplerX0Inpaint(self.model_wrap)
 
 
19
  self.device = device
20
  if scheduler not in self.SCHEDULERS:
21
  scheduler = self.SCHEDULERS[0]
 
7
  "lms", "dpm_fast", "dpm_adaptive", "dpmpp_2s_ancestral", "dpmpp_sde", "dpmpp_sde_gpu",
8
  "dpmpp_2m", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "ddim", "uni_pc", "uni_pc_bh2"]
9
 
10
+ def __init__(self, model, refiner_model, steps, device, sampler=None, scheduler=None, denoise=None, model_options={}):
11
  self.model = model
12
+ self.refiner_model = refiner_model
13
+
14
  self.model_denoise = CFGNoisePredictor(self.model)
15
+ self.refiner_model_denoise = CFGNoisePredictor(self.refiner_model)
16
+
17
  if self.model.model_type == model_base.ModelType.V_PREDICTION:
18
  self.model_wrap = CompVisVDenoiser(self.model_denoise, quantize=True)
19
  else:
20
  self.model_wrap = k_diffusion_external.CompVisDenoiser(self.model_denoise, quantize=True)
21
 
22
+ if self.refiner_model.model_type == model_base.ModelType.V_PREDICTION:
23
+ self.refiner_model_wrap = CompVisVDenoiser(self.refiner_model_denoise, quantize=True)
24
+ else:
25
+ self.refiner_model_wrap = k_diffusion_external.CompVisDenoiser(self.refiner_model_denoise, quantize=True)
26
+
27
  self.model_k = KSamplerX0Inpaint(self.model_wrap)
28
+ self.refiner_model_k = KSamplerX0Inpaint(self.refiner_model_wrap)
29
+
30
  self.device = device
31
  if scheduler not in self.SCHEDULERS:
32
  scheduler = self.SCHEDULERS[0]