mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-30 11:11:15 +00:00
Update forge_ipadapter.py
This commit is contained in:
@@ -1,15 +1,37 @@
|
||||
from modules_forge.shared import add_supported_control_model
|
||||
from modules_forge.supported_controlnet import ControlModelPatcher
|
||||
from IPAdapterPlus import IPAdapterApply
|
||||
|
||||
opIPAdapterApply = IPAdapterApply()
|
||||
|
||||
|
||||
class IPAdapterPatcher(ControlModelPatcher):
|
||||
@staticmethod
|
||||
def try_build_from_state_dict(state_dict, ckpt_path):
|
||||
a = 0
|
||||
return None
|
||||
model = state_dict
|
||||
|
||||
if ckpt_path.lower().endswith(".safetensors"):
|
||||
st_model = {"image_proj": {}, "ip_adapter": {}}
|
||||
for key in model.keys():
|
||||
if key.startswith("image_proj."):
|
||||
st_model["image_proj"][key.replace("image_proj.", "")] = model[key]
|
||||
elif key.startswith("ip_adapter."):
|
||||
st_model["ip_adapter"][key.replace("ip_adapter.", "")] = model[key]
|
||||
model = st_model
|
||||
|
||||
if "ip_adapter" not in model.keys() or not model["ip_adapter"]:
|
||||
return None
|
||||
|
||||
return IPAdapterPatcher(model)
|
||||
|
||||
def __init__(self, model_patcher):
|
||||
super().__init__(model_patcher)
|
||||
self.ipadapter = model_patcher
|
||||
return
|
||||
|
||||
def process_before_every_sampling(self, process, cond, *args, **kwargs):
|
||||
a = 0
|
||||
return
|
||||
|
||||
|
||||
add_supported_control_model(IPAdapterPatcher)
|
||||
|
||||
Reference in New Issue
Block a user