-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Krea realtime video #1011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Krea realtime video #1011
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import torch | ||
| from diffsynth import save_video | ||
| from diffsynth.pipelines.wan_video_new import WanVideoPipeline, ModelConfig | ||
|
|
||
|
|
||
| pipe = WanVideoPipeline.from_pretrained( | ||
| torch_dtype=torch.bfloat16, | ||
| device="cuda", | ||
| model_configs=[ | ||
| ModelConfig(model_id="krea/krea-realtime-video", origin_file_pattern="krea-realtime-video-14b.safetensors", offload_device="cpu"), | ||
| ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="models_t5_umt5-xxl-enc-bf16.pth", offload_device="cpu"), | ||
| ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="Wan2.1_VAE.pth", offload_device="cpu"), | ||
| ], | ||
| ) | ||
| pipe.enable_vram_management() | ||
|
|
||
| # Text-to-video | ||
| video = pipe( | ||
| prompt="a cat sitting on a boat", | ||
| num_inference_steps=6, num_frames=81, | ||
| seed=0, tiled=True, | ||
| cfg_scale=1, | ||
| sigma_shift=20, | ||
| ) | ||
| save_video(video, "video1.mp4", fps=15, quality=5) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| accelerate launch --config_file examples/wanvideo/model_training/full/accelerate_config_14B.yaml examples/wanvideo/model_training/train.py \ | ||
| --dataset_base_path data/example_video_dataset \ | ||
| --dataset_metadata_path data/example_video_dataset/metadata.csv \ | ||
| --height 480 \ | ||
| --width 832 \ | ||
| --dataset_repeat 100 \ | ||
| --model_id_with_origin_paths "krea/krea-realtime-video:krea-realtime-video-14b.safetensors,Wan-AI/Wan2.1-T2V-14B:models_t5_umt5-xxl-enc-bf16.pth,Wan-AI/Wan2.1-T2V-14B:Wan2.1_VAE.pth" \ | ||
| --learning_rate 1e-5 \ | ||
| --num_epochs 2 \ | ||
| --remove_prefix_in_ckpt "pipe.dit." \ | ||
| --output_path "./models/train/krea-realtime-video_full" \ | ||
| --trainable_models "dit" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| accelerate launch examples/wanvideo/model_training/train.py \ | ||
| --dataset_base_path data/example_video_dataset \ | ||
| --dataset_metadata_path data/example_video_dataset/metadata.csv \ | ||
| --height 480 \ | ||
| --width 832 \ | ||
| --dataset_repeat 100 \ | ||
| --model_id_with_origin_paths "krea/krea-realtime-video:krea-realtime-video-14b.safetensors,Wan-AI/Wan2.1-T2V-14B:models_t5_umt5-xxl-enc-bf16.pth,Wan-AI/Wan2.1-T2V-14B:Wan2.1_VAE.pth" \ | ||
| --learning_rate 1e-4 \ | ||
| --num_epochs 5 \ | ||
| --remove_prefix_in_ckpt "pipe.dit." \ | ||
| --output_path "./models/train/krea-realtime-video_lora" \ | ||
| --lora_base_model "dit" \ | ||
| --lora_target_modules "q,k,v,o,ffn.0,ffn.2" \ | ||
| --lora_rank 32 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import torch | ||
| from PIL import Image | ||
| from diffsynth import save_video, VideoData, load_state_dict | ||
|
Comment on lines
+2
to
+3
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| from diffsynth.pipelines.wan_video_new import WanVideoPipeline, ModelConfig | ||
|
|
||
|
|
||
| pipe = WanVideoPipeline.from_pretrained( | ||
| torch_dtype=torch.bfloat16, | ||
| device="cuda", | ||
| model_configs=[ | ||
| ModelConfig(model_id="krea/krea-realtime-video", origin_file_pattern="krea-realtime-video-14b.safetensors", offload_device="cpu"), | ||
| ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="models_t5_umt5-xxl-enc-bf16.pth", offload_device="cpu"), | ||
| ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="Wan2.1_VAE.pth", offload_device="cpu"), | ||
| ], | ||
| ) | ||
| state_dict = load_state_dict("models/train/krea-realtime-video_full/epoch-1.safetensors") | ||
| pipe.dit.load_state_dict(state_dict) | ||
| pipe.enable_vram_management() | ||
|
|
||
| # Text-to-video | ||
| video = pipe( | ||
| prompt="a cat sitting on a boat", | ||
| num_inference_steps=6, num_frames=81, | ||
| seed=0, tiled=True, | ||
| cfg_scale=1, | ||
| sigma_shift=20, | ||
| ) | ||
| save_video(video, "output.mp4", fps=15, quality=5) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import torch | ||
| from PIL import Image | ||
| from diffsynth import save_video, VideoData, load_state_dict | ||
|
Comment on lines
+2
to
+3
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| from diffsynth.pipelines.wan_video_new import WanVideoPipeline, ModelConfig | ||
|
|
||
|
|
||
| pipe = WanVideoPipeline.from_pretrained( | ||
| torch_dtype=torch.bfloat16, | ||
| device="cuda", | ||
| model_configs=[ | ||
| ModelConfig(model_id="krea/krea-realtime-video", origin_file_pattern="krea-realtime-video-14b.safetensors", offload_device="cpu"), | ||
| ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="models_t5_umt5-xxl-enc-bf16.pth", offload_device="cpu"), | ||
| ModelConfig(model_id="Wan-AI/Wan2.1-T2V-14B", origin_file_pattern="Wan2.1_VAE.pth", offload_device="cpu"), | ||
| ], | ||
| ) | ||
|
|
||
| pipe.load_lora(pipe.dit, "models/train/krea-realtime-video_lora/epoch-4.safetensors", alpha=1) | ||
| pipe.enable_vram_management() | ||
|
|
||
| # Text-to-video | ||
| video = pipe( | ||
| prompt="a cat sitting on a boat", | ||
| num_inference_steps=6, num_frames=81, | ||
| seed=0, tiled=True, | ||
| cfg_scale=1, | ||
| sigma_shift=20, | ||
| ) | ||
| save_video(video, "output.mp4", fps=15, quality=5) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段代码可以通过使用字典推导式来简化,使其更简洁、更符合Pythonic风格。例如: