tencent-ailab / IP-Adapter

The image prompt adapter is designed to enable a pretrained text-to-image diffusion model to generate images with image prompt.
Apache License 2.0
4.52k stars 298 forks source link

How to convert pytorch_model.bin weights into faceid.bin style? #237

Closed zhangn77 closed 6 months ago

zhangn77 commented 6 months ago

The following code is used to convert the old version of IP-adapter, `import torch ckpt = "checkpoint-50000/pytorch_model.bin" sd = torch.load(ckpt, map_location="cpu") image_proj_sd = {} ip_sd = {} for k in sd: if k.startswith("unet"): pass elif k.startswith("image_proj_model"): image_proj_sd[k.replace("image_proj_model.", "")] = sd[k] elif k.startswith("adapter_modules"): ip_sd[k.replace("adapter_modules.", "")] = sd[k]

torch.save({"image_proj": image_proj_sd, "ip_adapter": ip_sd}, "ip_adapter.bin")`

However, the faceid includes the lora weights, so how to revise above codes to convert pytorch_model.bin weights into faceid.bin style?

jeeveenn commented 5 months ago

Hi, may I ask how to solve this problem

zhangn77 commented 5 months ago

这是来自QQ邮箱的自动回复邮件。您好,您的邮件我已收到。会尽快查看会予以回复~祝您生活愉快!