Working POC for IP-Adapters. Not fully nodified yet, lots of caveats, hardwired model paths, etc.

This commit is contained in:
user1 2023-08-29 06:32:48 -07:00
parent 9f86cfa471
commit f2cd9e9ae2

View File

@ -63,9 +63,10 @@ from .compel import ConditioningField
from .controlnet_image_processors import ControlField from .controlnet_image_processors import ControlField
from .model import ModelInfo, UNetField, VaeField from .model import ModelInfo, UNetField, VaeField
DEFAULT_PRECISION = choose_precision(choose_torch_device())
DEFAULT_PRECISION = choose_precision(choose_torch_device())
SAMPLER_NAME_VALUES = Literal[tuple(list(SCHEDULER_MAP.keys()))] SAMPLER_NAME_VALUES = Literal[tuple(list(SCHEDULER_MAP.keys()))]
@ -215,6 +216,7 @@ class DenoiseLatentsInvocation(BaseInvocation):
default=None, default=None,
description=FieldDescriptions.mask, description=FieldDescriptions.mask,
) )
ip_adapter_image: Optional[ImageField] = InputField(input=Input.Connection)
@validator("cfg_scale") @validator("cfg_scale")
def ge_one(cls, v): def ge_one(cls, v):
@ -495,6 +497,13 @@ class DenoiseLatentsInvocation(BaseInvocation):
pipeline = self.create_pipeline(unet, scheduler) pipeline = self.create_pipeline(unet, scheduler)
conditioning_data = self.get_conditioning_data(context, scheduler, unet, seed) conditioning_data = self.get_conditioning_data(context, scheduler, unet, seed)
if self.ip_adapter_image is not None:
print("ip_adapter_image:", self.ip_adapter_image)
unwrapped_ip_adapter_image = context.services.images.get_pil_image(self.ip_adapter_image.image_name)
print("unwrapped ip_adapter_image:", unwrapped_ip_adapter_image)
else:
unwrapped_ip_adapter_image = None
control_data = self.prep_control_data( control_data = self.prep_control_data(
model=pipeline, model=pipeline,
context=context, context=context,
@ -523,7 +532,8 @@ class DenoiseLatentsInvocation(BaseInvocation):
masked_latents=masked_latents, masked_latents=masked_latents,
num_inference_steps=num_inference_steps, num_inference_steps=num_inference_steps,
conditioning_data=conditioning_data, conditioning_data=conditioning_data,
control_data=control_data, # list[ControlNetData] control_data=control_data, # list[ControlNetData],
ip_adapter_image=unwrapped_ip_adapter_image,
callback=step_callback, callback=step_callback,
) )