diff --git a/invokeai/app/invocations/latent.py b/invokeai/app/invocations/latent.py index 3c5552dfa3..acf5c70984 100644 --- a/invokeai/app/invocations/latent.py +++ b/invokeai/app/invocations/latent.py @@ -216,7 +216,9 @@ class DenoiseLatentsInvocation(BaseInvocation): default=None, description=FieldDescriptions.mask, ) - ip_adapter_image: Optional[ImageField] = InputField(input=Input.Connection) + ip_adapter_image: Optional[ImageField] = InputField(input=Input.Connection, title="IP Adapter Image", ui_order=6) + ip_adapter_strength: float = InputField(default=1.0, ge=0, le=2, ui_type=UIType.Float, + title="IP Adapter Strength", ui_order=7) @validator("cfg_scale") def ge_one(cls, v): @@ -534,6 +536,7 @@ class DenoiseLatentsInvocation(BaseInvocation): conditioning_data=conditioning_data, control_data=control_data, # list[ControlNetData], ip_adapter_image=unwrapped_ip_adapter_image, + ip_adapter_strength=self.ip_adapter_strength, callback=step_callback, ) diff --git a/invokeai/backend/stable_diffusion/diffusers_pipeline.py b/invokeai/backend/stable_diffusion/diffusers_pipeline.py index e9416c8057..edada58c8a 100644 --- a/invokeai/backend/stable_diffusion/diffusers_pipeline.py +++ b/invokeai/backend/stable_diffusion/diffusers_pipeline.py @@ -359,6 +359,7 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline): callback: Callable[[PipelineIntermediateState], None] = None, control_data: List[ControlNetData] = None, ip_adapter_image: Optional[PIL.Image] = None, + ip_adapter_strength: float = 1.0, mask: Optional[torch.Tensor] = None, masked_latents: Optional[torch.Tensor] = None, seed: Optional[int] = None, @@ -411,6 +412,7 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline): additional_guidance=additional_guidance, control_data=control_data, ip_adapter_image=ip_adapter_image, + ip_adapter_strength=ip_adapter_strength, callback=callback, ) finally: @@ -431,6 +433,7 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline): additional_guidance: List[Callable] = None, control_data: List[ControlNetData] = None, ip_adapter_image: Optional[PIL.Image] = None, + ip_adapter_strength: float = 1.0, callback: Callable[[PipelineIntermediateState], None] = None, ): @@ -463,6 +466,7 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline): ip_adapter_model_path, # hardwiring to manually downloaded loc for first pass "cuda") # hardwiring CUDA GPU for first pass # IP-Adapter ==> add additional cross-attention layers to UNet model here? + ip_adapter.set_scale(ip_adapter_strength) print("ip_adapter:", ip_adapter) # get image embedding from CLIP and ImageProjModel