diff --git a/modules/ipadapter.py b/modules/ipadapter.py index 00bc714c8..41e336573 100644 --- a/modules/ipadapter.py +++ b/modules/ipadapter.py @@ -103,7 +103,7 @@ def apply(pipe, p: processing.StableDiffusionProcessing, adapter_names=[], adapt adapter_images = p.ip_adapter_images adapter_images = get_images(adapter_images) adapter_scales = get_scales(adapter_scales, adapter_images) - + p.ip_adapter_scales = adapter_scales # init code if pipe is None: return False diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 1cfa62ef1..081e37991 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -66,6 +66,16 @@ def process_diffusers(p: processing.StableDiffusionProcessing): time.sleep(0.1) if kwargs.get('latents', None) is None: return kwargs + if True: # TODO: IP adapter active + ip_adapter_scales = p.ip_adapter_scales + ip_adapter_end = shared.opts.data.get("ip_adapter_end", 1) + ip_adapter_end = ip_adapter_end if isinstance(ip_adapter_end, list) else [ip_adapter_end] * len(ip_adapter_scales) + if any(end != 1 for end in ip_adapter_end): + for i, end in enumerate(ip_adapter_end): + if step >= int(pipe.num_timesteps * end): + ip_adapter_scales[i] = 0 + if ip_adapter_scales != p.ip_adapter_scales: + pipe.set_ip_adapter_scale(ip_adapter_scales) if step != pipe.num_timesteps: kwargs = processing_correction.correction_callback(p, timestep, kwargs) if p.scheduled_prompt and 'prompt_embeds' in kwargs and 'negative_prompt_embeds' in kwargs: diff --git a/scripts/xyz_grid.py b/scripts/xyz_grid.py index bb28c7e8a..b10b6b1bb 100644 --- a/scripts/xyz_grid.py +++ b/scripts/xyz_grid.py @@ -275,6 +275,7 @@ axis_options = [ AxisOption("[FreeU] 2nd stage skip factor", float, apply_setting('freeu_s2')), AxisOption("[IP adapter] Name", str, apply_field('ip_adapter_names'), cost=1.0, choices=lambda: list(ipadapter.ADAPTERS)), AxisOption("[IP adapter] Scale", float, apply_field('ip_adapter_scales')), + AxisOption("[IP adapter] End", float, apply_setting('ip_adapter_end')), ]