google / prompt-to-prompt

Apache License 2.0
2.98k stars 279 forks source link

Can't load a fine-tuned model due to using an old version of diffusers #66

Open efsansokmen opened 11 months ago

efsansokmen commented 11 months ago

Hi, I am launching your notebook prompt-to-prompt_stable.ipynb. I would like to be able to load the weights of a fine-tuned diffusion model into the pipeline. A reproducible section of the code I try to execute is the following:

 device = "cuda:0"
# load model
model_path = "/local/path/to/checkpoint-100/"
pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float16,
    safety_checker=None,
    feature_extractor=None,
    requires_safety_checker=False
)

# load weights from fine-tuned model
pipe.unet.load_attn_procs(pretrained_model_name_or_path_or_dict=model_path, subfolder="checkpoint-100", weight_name="pytorch_model.bin")
pipe.to(device)

Here is the error: AttributeError: 'UNet2DConditionModel' object has no attribute 'load_attn_procs' which is triggered by the line: pipe.unet.load_attn_procs(pretrained_model_name_or_path_or_dict=model_path, subfolder="checkpoint-100", weight_name="pytorch_model.bin") FYI, the code works perfectly for diffusers version 0.19.0, however, fails for the version 0.8.0 which is used by your code.

Could you update your code so that it works for later versions, or guide me for a fix? Thanks in advance~