Skip to content

Commit

Permalink
Support diffusers format t2i adapters.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Sep 8, 2023
1 parent ff96209 commit 1e6b671
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions comfy/controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,18 @@ def copy(self):
return c

def load_t2i_adapter(t2i_data):
keys = t2i_data.keys()
if 'adapter' in keys:
if 'adapter' in t2i_data:
t2i_data = t2i_data['adapter']
keys = t2i_data.keys()
if 'adapter.body.0.resnets.0.block1.weight' in t2i_data: #diffusers format
prefix_replace = {}
for i in range(4):
for j in range(2):
prefix_replace["adapter.body.{}.resnets.{}.".format(i, j)] = "body.{}.".format(i * 2 + j)
prefix_replace["adapter.body.{}.".format(i, j)] = "body.{}.".format(i * 2)
prefix_replace["adapter."] = ""
t2i_data = comfy.utils.state_dict_prefix_replace(t2i_data, prefix_replace)
keys = t2i_data.keys()

if "body.0.in_conv.weight" in keys:
cin = t2i_data['body.0.in_conv.weight'].shape[1]
model_ad = comfy.t2i_adapter.adapter.Adapter_light(cin=cin, channels=[320, 640, 1280, 1280], nums_rb=4)
Expand Down

0 comments on commit 1e6b671

Please sign in to comment.