diff --git a/py/easyNodes.py b/py/easyNodes.py index 6e4465a..dc71a2c 100644 --- a/py/easyNodes.py +++ b/py/easyNodes.py @@ -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) diff --git a/py/ic_light/func.py b/py/ic_light/func.py index 7f8f94e..53c57c3 100644 --- a/py/ic_light/func.py +++ b/py/ic_light/func.py @@ -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 \ No newline at end of file + return (work_model, ic_model) \ No newline at end of file