prompt-to-prompt icon indicating copy to clipboard operation
prompt-to-prompt copied to clipboard

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

Open efsansokmen opened this issue 1 year ago • 0 comments

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~

efsansokmen avatar Aug 15 '23 09:08 efsansokmen