From 167b903ed825182db577f95c63c79f263fbe50a2 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 4 Dec 2023 19:16:12 -0500 Subject: [PATCH] add additional ip-adapters --- CHANGELOG.md | 8 +++++++- modules/processing.py | 5 ++++- scripts/ipadapter.py | 13 +++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71749b1ca..dbc1784db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,14 @@ ## Update for 2023-12-05 +*Note*: based on `diffusers==0.25.0.dev0` + +- **Diffusers** + - **IP Adapter** add support for `ip-adapter-plus_sd15` and `ip-adapter-plus-face_sd15` - **General** - - **Extra networks** new settting -> extra networks -> build info on first access + - **LoRA** add support for block weights, thanks @AI-Casanova + example `` + - **Extra networks** new *settting -> extra networks -> build info on first access* indexes all networks on first access instead of server startup - disable google fonts check on server startup - fix torchvision/basicsr compatibility diff --git a/modules/processing.py b/modules/processing.py index b04388d8f..3f115377f 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -705,13 +705,15 @@ def process_images(p: StableDiffusionProcessing) -> Processed: modules.sd_vae.reload_vae_weights() shared.prompt_styles.apply_styles_to_extra(p) - + print('HERE1') if not shared.opts.cuda_compile: modules.sd_models.apply_token_merging(p.sd_model, p.get_token_merging_ratio()) modules.sd_hijack_freeu.apply_freeu(p, shared.backend == shared.Backend.ORIGINAL) + print('HERE2') modules.script_callbacks.before_process_callback(p) + print('HERE3') if shared.cmd_opts.profile: import cProfile profile_python = cProfile.Profile() @@ -732,6 +734,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed: else: with context_hypertile_vae(p), context_hypertile_unet(p): res = process_images_inner(p) + print('HERE4') finally: if not shared.opts.cuda_compile: diff --git a/scripts/ipadapter.py b/scripts/ipadapter.py index 797ff2785..cadd24c6e 100644 --- a/scripts/ipadapter.py +++ b/scripts/ipadapter.py @@ -8,6 +8,7 @@ TODO: - SD/SDXL autodetect """ +import time import gradio as gr from modules import scripts, processing, shared, devices @@ -18,11 +19,11 @@ ADAPTERS = [ 'none', 'models/ip-adapter_sd15', 'models/ip-adapter_sd15_light', - # 'models/ip-adapter_sd15_vit-G', # RuntimeError: mat1 and mat2 shapes cannot be multiplied (2x1024 and 1280x3072) - # 'models/ip-adapter-plus_sd15', # KeyError: 'proj.weight' - # 'models/ip-adapter-plus-face_sd15', # KeyError: 'proj.weight' + 'models/ip-adapter-plus_sd15', + 'models/ip-adapter-plus-face_sd15', # 'models/ip-adapter-full-face_sd15', # KeyError: 'proj.weight' 'sdxl_models/ip-adapter_sdxl', + # 'models/ip-adapter_sd15_vit-G', # RuntimeError: mat1 and mat2 shapes cannot be multiplied (2x1024 and 1280x3072) # 'sdxl_models/ip-adapter_sdxl_vit-h', # 'sdxl_models/ip-adapter-plus_sdxl_vit-h', # 'sdxl_models/ip-adapter-plus-face_sdxl_vit-h', @@ -89,13 +90,17 @@ class Script(scripts.Script): # main code subfolder, model = adapter.split('/') if model != loaded or getattr(shared.sd_model.unet.config, 'encoder_hid_dim_type', None) is None: + t0 = time.time() if loaded is not None: shared.log.debug('IP adapter: reset attention processor') shared.sd_model.unet.set_default_attn_processor() loaded = None - shared.log.info(f'IP adapter load: adapter="{model}" scale={scale} image={image}') + else: + shared.log.debug('IP adapter: load attention processor') shared.sd_model.image_encoder = image_encoder shared.sd_model.load_ip_adapter("h94/IP-Adapter", subfolder=subfolder, weight_name=f'{model}.safetensors') + t1 = time.time() + shared.log.info(f'IP adapter load: adapter="{model}" scale={scale} image={image} time={t1-t0:.2f}') loaded = model else: shared.log.debug(f'IP adapter cache: adapter="{model}" scale={scale} image={image}')