modelscope / modelscope/DiffSynth-Studio
Shape error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.1k
- Forks
- 1.3k
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 45
Description
Traceback (most recent call last):
File "/2021533110/DiffSynth-Studio/examples/wanvideo/model_training/validate_lora/Wan2.1-VACE-14B.py", line 22, in
video = pipe(
File "/root/miniconda3/envs/videogen/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/2021533110/DiffSynth-Studio/diffsynth/pipelines/wan_video_new.py", line 583, in call
noise_pred_posi = self.model_fn(**models, **inputs_shared, **inputs_posi, timestep=timestep)
File "/2021533110/DiffSynth-Studio/diffsynth/pipelines/wan_video_new.py", line 1161, in model_fn_wan_video
vace_hints = vace(x, vace_context, context, t_mod, freqs)
File "/root/miniconda3/envs/videogen/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/root/miniconda3/envs/videogen/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl
return forward_call(*args, **kwargs)
File "/2021533110/DiffSynth-Studio/diffsynth/models/wan_video_vace.py", line 60, in forward
c = torch.cat([
File "/2021533110/DiffSynth-Studio/diffsynth/models/wan_video_vace.py", line 61, in
torch.cat([u, u.new_zeros(1, x.shape[1] - u.size(1), u.size(2))],
RuntimeError: Trying to create tensor with negative dimension -2880: [1, -2880, 5120
Here is my lora script:
accelerate launch examples/wanvideo/model_training/train.py
--dataset_base_path /2021533110/VideoX-Fun_my/datasets/finetune_dataset_processed
--dataset_metadata_path /2021533110/VideoX-Fun_my/datasets/finetune_dataset_processed/metadata_long.csv
--data_file_keys "video,vace_video,vace_reference_image,prompt"
--height 544
--width 960
--num_frames 17
--dataset_repeat 1
--model_id_with_origin_paths "Wan-AI/Wan2.1-VACE-14B:diffusion_pytorch_model*.safetensors,Wan-AI/Wan2.1-VACE-14B:models_t5_umt5-xxl-enc-bf16.pth,Wan-AI/Wan2.1-VACE-14B:Wan2.1_VAE.pth"
--learning_rate 1e-4
--num_epochs 100
--remove_prefix_in_ckpt "pipe.vace."
--output_path "./models/train/Wan2.1-VACE-14B_lora"
--lora_base_model "vace"
--lora_target_modules "q,k,v,o,ffn.0,ffn.2"
--lora_rank 32
--extra_inputs "vace_video,vace_reference_image"
--use_gradient_checkpointing_offload
Here is my inference script:
import torch
from PIL import Image
from diffsynth import save_video, VideoData
from diffsynth.pipelines.wan_video_new import WanVideoPipeline, ModelConfig
pipe = WanVideoPipeline.from_pretrained(
torch_dtype=torch.bfloat16,
device="cuda",
model_configs=[
ModelConfig(model_id="Wan-AI/Wan2.1-VACE-14B", origin_file_pattern="diffusion_pytorch_model*.safetensors", offload_device="cpu"),
ModelConfig(model_id="Wan-AI/Wan2.1-VACE-14B", origin_file_pattern="models_t5_umt5-xxl-enc-bf16.pth", offload_device="cpu"),
ModelConfig(model_id="Wan-AI/Wan2.1-VACE-14B", origin_file_pattern="Wan2.1_VAE.pth", offload_device="cpu"),
],
)
pipe.load_lora(pipe.vace, "/2021533110/DiffSynth-Studio/models/train/Wan2.1-VACE-14B_lora/epoch-98.safetensors", alpha=1)
pipe.enable_vram_management()
video = VideoData("/2021533110/VideoX-Fun_my/datasets/data/test1/flow.mp4", height=544, width=960)
video = [video[i] for i in range(17)]
reference_image = VideoData("/2021533110/VACE/data/coser5/coser5_0528_2203_00109_.mp4", height=544, width=960)[0]
video = pipe(
prompt="A beautiful young woman in an elegant, traditional Chinese-inspired fantasy outfit, standing under a tunnel of blooming cherry blossom trees. She wears a rich purple and gold embroidered dress with a white inner layer, detailed with ornate patterns and ribbon knots. Her long black hair is styled into twin ponytails adorned with golden hair ornaments and floral accessories. She poses gracefully with arms slightly extended, her expression calm and serene. The background features symmetrical rows of large cherry trees in full bloom, their pink petals forming a dreamy canopy above a quiet stone path. Soft lighting and pastel tones create a peaceful, romantic spring atmosphere. --v 5 --ar 16:9 --style photographic --quality 2",
negative_prompt="色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走",
vace_video=video, vace_reference_image=reference_image, num_frames=17,
seed=1, tiled=True
)
save_video(video, "video_Wan2.1-VACE-14B.mp4", fps=15, quality=5)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the inference script and inspect diffsynth/models/wan_video_vace.py at lines 60-61, then trace the tensor inputs from diffsynth/pipelines/wan_video_new.py line 1161. Compare the shapes produced by the training and inference inputs; done means the reported negative-dimension error is understood and the VACE inference run completes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100