Can't use popular LORA's with Hello World Example

#12
by v12h - opened

This code only gets to "Loading LoRA" then gives this error:

image.png

This is not only particular to this LORA, but other ones as well. Does anybody see anything wrong with my implementation of loading LoRA's for WAN2.1 I2V 14B?

Thank you.

model_id = "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers"
image_encoder = CLIPVisionModel.from_pretrained(
model_id, subfolder="image_encoder", torch_dtype=torch.float32
)
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
pipe = WanImageToVideoPipeline.from_pretrained(
model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16
)

# replace this with pipe.to("cuda") if you have sufficient VRAM
pipe.enable_sequential_cpu_offload()

print("Loading LoRA...")
pipe.load_lora_weights(
    os.path.join('lora', 'SU_Twrk_EP55.safetensors'),
    adapter_name="SU_Twrk_EP55",
    adapter_weights=[1.0]
)
print("LoRA loaded")
image = load_image(
    "./saved/generated_20250617_192120_1.png"
)

max_area = 480 * 480
aspect_ratio = image.height / image.width
mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]
height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
image = image.resize((width, height))

prompt = (
    "an anime girl with wings floating in the sky"
)
negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"

num_frames = 33

print("Generating video...")
output = pipe(
    image=image,
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=height,
    width=width,
    num_frames=num_frames,
    guidance_scale=5.0,
).frames[0]
export_to_video(output, "wan-i2v.mp4", fps=16)

Sign up or log in to comment