lllyasviel commited on
Commit
36fc6d0
·
1 Parent(s): a1689ad
Files changed (3) hide show
  1. launch.py +1 -1
  2. modules/core.py +7 -7
  3. modules/samplers_advanced.py +1 -2
launch.py CHANGED
@@ -20,7 +20,7 @@ def prepare_environment():
20
  xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.20')
21
 
22
  comfy_repo = os.environ.get('COMFY_REPO', "https://github.com/comfyanonymous/ComfyUI")
23
- comfy_commit_hash = os.environ.get('COMFY_COMMIT_HASH', "c9b562aed153cb35d4ce4126caf86995b0c63b12")
24
 
25
  print(f"Python {sys.version}")
26
  print(f"Fooocus version: {fooocus_version.version}")
 
20
  xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.20')
21
 
22
  comfy_repo = os.environ.get('COMFY_REPO', "https://github.com/comfyanonymous/ComfyUI")
23
+ comfy_commit_hash = os.environ.get('COMFY_COMMIT_HASH', "2bc12d3d22efb5c63ae3a7fc342bb2dd16b31735")
24
 
25
  print(f"Python {sys.version}")
26
  print(f"Fooocus version: {fooocus_version.version}")
modules/core.py CHANGED
@@ -9,7 +9,7 @@ import comfy.utils
9
 
10
  from comfy.sd import load_checkpoint_guess_config
11
  from nodes import VAEDecode, EmptyLatentImage, CLIPTextEncode
12
- from comfy.sample import prepare_mask, broadcast_cond, get_additional_models, cleanup_additional_models
13
  from modules.samplers_advanced import KSampler, KSamplerWithRefiner
14
  from modules.patch import patch_all
15
 
@@ -133,6 +133,8 @@ def ksampler(model, positive, negative, latent, seed=None, steps=30, cfg=7.0, sa
133
  if noise_mask is not None:
134
  noise_mask = prepare_mask(noise_mask, noise.shape, device)
135
 
 
 
136
  real_model = model.model
137
 
138
  noise = noise.to(device)
@@ -141,9 +143,7 @@ def ksampler(model, positive, negative, latent, seed=None, steps=30, cfg=7.0, sa
141
  positive_copy = broadcast_cond(positive, noise.shape[0], device)
142
  negative_copy = broadcast_cond(negative, noise.shape[0], device)
143
 
144
- models = get_additional_models(positive, negative)
145
- comfy.model_management.load_models_gpu([model] + models, comfy.model_management.batch_area_memory(
146
- noise.shape[0] * noise.shape[2] * noise.shape[3]))
147
 
148
  sampler = KSampler(real_model, steps=steps, device=device, sampler=sampler_name, scheduler=scheduler,
149
  denoise=denoise, model_options=model.model_options)
@@ -206,6 +206,8 @@ def ksampler_with_refiner(model, positive, negative, refiner, refiner_positive,
206
  if noise_mask is not None:
207
  noise_mask = prepare_mask(noise_mask, noise.shape, device)
208
 
 
 
209
  noise = noise.to(device)
210
  latent_image = latent_image.to(device)
211
 
@@ -215,9 +217,7 @@ def ksampler_with_refiner(model, positive, negative, refiner, refiner_positive,
215
  refiner_positive_copy = broadcast_cond(refiner_positive, noise.shape[0], device)
216
  refiner_negative_copy = broadcast_cond(refiner_negative, noise.shape[0], device)
217
 
218
- models = get_additional_models(positive, negative)
219
- comfy.model_management.load_models_gpu([model] + models, comfy.model_management.batch_area_memory(
220
- noise.shape[0] * noise.shape[2] * noise.shape[3]))
221
 
222
  sampler = KSamplerWithRefiner(model=model, refiner_model=refiner, steps=steps, device=device,
223
  sampler=sampler_name, scheduler=scheduler,
 
9
 
10
  from comfy.sd import load_checkpoint_guess_config
11
  from nodes import VAEDecode, EmptyLatentImage, CLIPTextEncode
12
+ from comfy.sample import prepare_mask, broadcast_cond, load_additional_models, cleanup_additional_models
13
  from modules.samplers_advanced import KSampler, KSamplerWithRefiner
14
  from modules.patch import patch_all
15
 
 
133
  if noise_mask is not None:
134
  noise_mask = prepare_mask(noise_mask, noise.shape, device)
135
 
136
+ comfy.model_management.load_model_gpu(model)
137
+
138
  real_model = model.model
139
 
140
  noise = noise.to(device)
 
143
  positive_copy = broadcast_cond(positive, noise.shape[0], device)
144
  negative_copy = broadcast_cond(negative, noise.shape[0], device)
145
 
146
+ models = load_additional_models(positive, negative, model.model_dtype())
 
 
147
 
148
  sampler = KSampler(real_model, steps=steps, device=device, sampler=sampler_name, scheduler=scheduler,
149
  denoise=denoise, model_options=model.model_options)
 
206
  if noise_mask is not None:
207
  noise_mask = prepare_mask(noise_mask, noise.shape, device)
208
 
209
+ comfy.model_management.load_model_gpu(model)
210
+
211
  noise = noise.to(device)
212
  latent_image = latent_image.to(device)
213
 
 
217
  refiner_positive_copy = broadcast_cond(refiner_positive, noise.shape[0], device)
218
  refiner_negative_copy = broadcast_cond(refiner_negative, noise.shape[0], device)
219
 
220
+ models = load_additional_models(positive, negative, model.model_dtype())
 
 
221
 
222
  sampler = KSamplerWithRefiner(model=model, refiner_model=refiner, steps=steps, device=device,
223
  sampler=sampler_name, scheduler=scheduler,
modules/samplers_advanced.py CHANGED
@@ -152,8 +152,7 @@ class KSamplerWithRefiner:
152
  noise.shape[3], noise.shape[2], self.device, "negative")
153
 
154
  def refiner_switch():
155
- comfy.model_management.load_models_gpu([self.refiner_model_patcher], comfy.model_management.batch_area_memory(
156
- noise.shape[0] * noise.shape[2] * noise.shape[3]))
157
  self.model_denoise.inner_model = self.refiner_model_denoise.inner_model
158
  for i in range(len(positive)):
159
  positive[i] = refiner_positive[i]
 
152
  noise.shape[3], noise.shape[2], self.device, "negative")
153
 
154
  def refiner_switch():
155
+ comfy.model_management.load_model_gpu(self.refiner_model_patcher)
 
156
  self.model_denoise.inner_model = self.refiner_model_denoise.inner_model
157
  for i in range(len(positive)):
158
  positive[i] = refiner_positive[i]