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
5.27k stars 336 forks source link

Training issues #166

Open RichFrain opened 11 months ago

RichFrain commented 11 months ago

Hi! This is structure my training data. The training was done according to the instructions. But after I trained and converted the resulting model.safetensors to ip_adapter.bin, I found that sd["ip_adapter"].keys() was empty, I don't know what the problem is. image image

xiaohu2015 commented 11 months ago

you can try this: https://github.com/tencent-ailab/IP-Adapter/issues/164

RichFrain commented 11 months ago

Dear Author, I followed that. I found that sd["ip_adapter"].keys() is still empty image

xiaohu2015 commented 11 months ago
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("image_proj_model"):
        image_proj_sd[k.replace("image_proj_model.", "")] = sd[k]
    elif "_ip." in k: 
        ip_sd[k.replace("unet.", "")] = sd[k] 

torch.save({"image_proj": image_proj_sd, "ip_adapter": ip_sd}, "ip_adapter.bin")
RichFrain commented 11 months ago

Didn't get pytorch_model.bin file after training, I need to convert the model.safetensors file to a pytorch_model.bin file, right? image

xiaohu2015 commented 11 months ago

Dear Author, I followed that. I found that sd["ip_adapter"].keys() is still empty image

just like this to read safetensors

RichFrain commented 11 months ago

I apologize for bothering you so many times because I love this project so much! After I loaded safetensors converted to ip_adapter.bin. The output sd["ip_adapter"].keys() is Figure 2, which is not the same as the official sd["ip_adapter"].keys() output, which is Figure 1, which is official. Loading the converted ip_adapter.bin during testing reports an error. image image image

xiaohu2015 commented 11 months ago

please refer to https://github.com/tencent-ailab/IP-Adapter/issues/168

404289680 commented 11 months ago

sdxl model,KeyError: 'down_blocks.1.attentions.0.transformer_blocks.1.attn2.processor.to_k_ip.weight'

AbhinavJangra29 commented 2 months ago

hey , did it get solve?