fix:iclight cache bug #173

This commit is contained in:
yolain
2024-05-17 17:00:39 +08:00
parent 7715ebfd06
commit 24526623fb
2 changed files with 11 additions and 9 deletions
+7 -6
View File
@@ -2255,15 +2255,16 @@ class icLightApply:
latent, = VAEEncodeArgMax().encode(vae, image)
key = 'iclight_' + mode + '_' + model_type
model_path = get_local_filepath(IC_LIGHT_MODELS[mode]['sd1']["model_url"],
os.path.join(folder_paths.models_dir, "unet"))
ic_model = None
if key in backend_cache.cache:
log_node_info("easy icLightApply", f"Using icLightModel {mode+'_'+model_type} Cached")
_, m = backend_cache.cache[key][1]
_, ic_model = backend_cache.cache[key][1]
m, _ = iclight.apply(model_path, model, latent, ic_model)
else:
model_path = get_local_filepath(IC_LIGHT_MODELS[mode]['sd1']["model_url"],
os.path.join(folder_paths.models_dir, "unet"))
m = iclight.apply(model_path, model, latent)
backend_cache.update_cache(key, 'iclight', (False, m))
m, ic_model = iclight.apply(model_path, model, latent, ic_model)
backend_cache.update_cache(key, 'iclight', (False, ic_model))
return (m, lighting_image)
+4 -3
View File
@@ -139,7 +139,7 @@ class ICLight:
return image
def apply(self, ic_model_path, model: ModelPatcher, c_concat: dict,) -> Tuple[ModelPatcher]:
def apply(self, ic_model_path, model: ModelPatcher, c_concat: dict, ic_model=None) -> Tuple[ModelPatcher]:
try:
ModelPatcher.calculate_weight = calculate_weight_adjust_channel(ModelPatcher.calculate_weight)
except:
@@ -171,7 +171,8 @@ class ICLight:
return existing_wrapper(unet_apply, params=self.apply_c_concat(params, concat_conds))
work_model.set_model_unet_function_wrapper(wrapper_func)
ic_model = load_unet(ic_model_path)
if not ic_model:
ic_model = load_unet(ic_model_path)
ic_model_state_dict = ic_model.model.diffusion_model.state_dict()
work_model.add_patches(
@@ -181,4 +182,4 @@ class ICLight:
}
)
return work_model
return (work_model, ic_model)