Downloads · 30 days
54
12% of all-time downloads
joyfox/Wan2.1-Mecha-LoRA
Wan2.1-Mecha-LoRA is a image-to-video model from joyfox. Use it for the image-to-video task on the model card, and read the license before you ship it in a product. It is set up for diffusers. The card lists the license as apache-2.0.
<div style="background-color: f8f9fa; padding: 20px; border-radius: 10px; margin-bottom: 20px;" <h1 style="color: 24292e; margin-top: 0;"valiantcat LoRA for Wan2.1 14B I2V 720p</h1
Downloads · 30 days
54
12% of all-time downloads
All-time downloads
462
Public
Repo size
386 MB
Likes
0
Public
Click a slice to open those files.
.safetensors359 MB · 93%
From the Hugging Face model README
pip install git+https://github.com/huggingface/diffusers.git
import torch
from diffusers.utils import export_to_video, load_image
from diffusers import AutoencoderKLWan, WanImageToVideoPipeline
from transformers import CLIPVisionModel
import numpy as np
model_id = "Wan-AI/Wan2.1-I2V-14B-720P-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)
pipe.to("cuda")
pipe.load_lora_weights("valiantcat/Wan2.1-Mecha-LoRA")
pipe.enable_model_cpu_offload() #for low-vram environments
prompt = "gangtiexia,背景保持不变,这个人开始变身红色机甲,变身过程中出现机甲面罩遮住脸部,变身完成之后这个人向前走."
image = load_image("https://huggingface.co/valiantcat/Wan2.1-Mecha-LoRA/blob/main/result/test.jpg")
max_area = 512 * 768
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))
output = pipe(
image=image,
prompt=prompt,
height=height,
width=width,
num_frames=81,
guidance_scale=5.0,
num_inference_steps=25
).frames[0]
export_to_video(output, "output.mp4", fps=16)