Safetensors
Bujiazi commited on
Commit
fcf4f97
·
verified ·
1 Parent(s): 64d7a62

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -1
README.md CHANGED
@@ -48,7 +48,43 @@ The `adapter_model.safetensors` is based on [WAN-2.2-TI2V](https://huggingface.c
48
 
49
  ## 🚀 Inference
50
  ```
51
- TBD
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  ```
53
 
54
 
 
48
 
49
  ## 🚀 Inference
50
  ```
51
+ import torch
52
+ from huggingface_hub import snapshot_download
53
+ from diffusers import WanPipeline, AutoencoderKLWan
54
+ from diffusers.utils import export_to_video
55
+ from peft import PeftModel
56
+
57
+ dtype = torch.bfloat16
58
+ device = "cuda"
59
+
60
+ model_id = "Wan-AI/Wan2.2-TI2V-5B-Diffusers"
61
+ checkpoint = snapshot_download(repo_id="Bujiazi/HPSD", repo_type="model")
62
+
63
+ vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
64
+ pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=dtype)
65
+ pipe.to(device)
66
+
67
+ pipe.transformer = PeftModel.from_pretrained(pipe.transformer, checkpoint, torch_dtype=dtype).to(device)
68
+
69
+ height = 704
70
+ width = 1280
71
+ num_frames = 81
72
+ num_inference_steps = 50
73
+ guidance_scale = 5.0
74
+
75
+ prompt = "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
76
+ negative_prompt = "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
77
+
78
+ output = pipe(
79
+ prompt=prompt,
80
+ negative_prompt=negative_prompt,
81
+ height=height,
82
+ width=width,
83
+ num_frames=num_frames,
84
+ guidance_scale=guidance_scale,
85
+ num_inference_steps=num_inference_steps,
86
+ ).frames[0]
87
+ export_to_video(output, "hpsd_test.mp4", fps=16)
88
  ```
89
 
90