Added IP-Adapter SDXL support. Added IP-Adapter "Plus" (more detail) model support.

This commit is contained in:
user1 2023-09-01 04:40:30 -07:00
parent 74bfb5e1f9
commit fb1b03960e

View File

@ -34,7 +34,7 @@ from .diffusion import (
BasicConditioningInfo, BasicConditioningInfo,
) )
from ..util import normalize_device, auto_detect_slice_size from ..util import normalize_device, auto_detect_slice_size
from invokeai.backend.ip_adapter.ip_adapter import IPAdapter from invokeai.backend.ip_adapter.ip_adapter import IPAdapter, IPAdapterPlus, IPAdapterXL
@dataclass @dataclass
@ -467,6 +467,21 @@ class StableDiffusionGeneratorPipeline(StableDiffusionPipeline):
# and how to undo if ip_adapter_image is removed # and how to undo if ip_adapter_image is removed
# Should reimplement to use existing model management context etc. # Should reimplement to use existing model management context etc.
# #
if "sdxl" in ip_adapter_info.ip_adapter_model:
print("using IPAdapterXL")
ip_adapter = IPAdapterXL(self,
ip_adapter_info.image_encoder_model,
ip_adapter_info.ip_adapter_model,
self.unet.device)
elif "plus" in ip_adapter_info.ip_adapter_model:
print("using IPAdapterPlus")
ip_adapter = IPAdapterPlus(self, # IPAdapterPlus first arg is StableDiffusionPipeline
ip_adapter_info.image_encoder_model,
ip_adapter_info.ip_adapter_model,
self.unet.device,
num_tokens=16)
else:
print("using IPAdapter")
ip_adapter = IPAdapter(self, # IPAdapter first arg is StableDiffusionPipeline ip_adapter = IPAdapter(self, # IPAdapter first arg is StableDiffusionPipeline
ip_adapter_info.image_encoder_model, ip_adapter_info.image_encoder_model,
ip_adapter_info.ip_adapter_model, ip_adapter_info.ip_adapter_model,