SimpleTuner icon indicating copy to clipboard operation
SimpleTuner copied to clipboard

ValueError: Invalid LoRA checkpoint.

Open Gavin-Wells opened this issue 2 years ago • 2 comments

When I loaded flux lora checkpoint,It shows ValueError: Invalid LoRA checkpoint.

Traceback (most recent call last):
  File "/userdata136/FLUX.1-dev/tr.py", line 5, in <module>
    pipe.load_lora_weights('/root/user/FLUX.1-dev/loras/pytorch_lora_weights.safetensors', weight_name="pytorch_lora_weights.safetensors")
  File "/root/miniconda3/lib/python3.9/site-packages/diffusers/loaders/lora_pipeline.py", line 1639, in load_lora_weights
    raise ValueError("Invalid LoRA checkpoint.")
ValueError: Invalid LoRA checkpoint.

The code is:

import torch
from diffusers import FluxPipeline, FluxTransformer2DModel

pipe = FluxPipeline.from_pretrained("/root/user/FLUX.1-dev", torch_dtype=torch.bfloat16)
pipe.load_lora_weights('/root/user/FLUX.1-dev/loras', weight_name="pytorch_lora_weights.safetensors")
pipe=pipe.to("cuda")

prompt = ""
image = pipe(
    prompt,
    height=1344,
    width=768,
    guidance_scale=3.5,
    output_type="pil",
    num_inference_steps=50,
    max_sequence_length=512,
    generator=torch.Generator(device="cuda").manual_seed(0),
    joint_attention_kwargs={"scale": 1.0}
).images[0]
image.save("flux-dev.png")

Can I ask what's wrong?

Gavin-Wells avatar Aug 27 '24 05:08 Gavin-Wells

use the model card code example

bghira avatar Aug 27 '24 12:08 bghira

Hi,could you please share the example code with me?

xcltql666 avatar Dec 13 '24 02:12 xcltql666