Views
No views yet
| art_is_explosion | storm_magic |
|---|---|
| dark_magic | kiss_camera |
| bullet_time | truman_show |
| fire_breath | blooming_flowers |
| four_seasons | spiral_ascent |
art_is_explosion + storm_magic1git clone https://github.com/modelscope/DiffSynth-Studio.git
2cd DiffSynth-Studio
3pip install -e ".[all]"1import torch
2from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
3from safetensors.torch import save_file1vram_config = {
2 "offload_dtype": "disk",
3 "offload_device": "disk",
4 "onload_dtype": "disk",
5 "onload_device": "disk",
6 "preparing_dtype": torch.bfloat16,
7 "preparing_device": "cuda",
8 "computation_dtype": torch.bfloat16,
9 "computation_device": "cuda",
10}
11pipe = MiniMaxH3Pipeline.from_pretrained(
12 torch_dtype=torch.bfloat16,
13 device="cuda",
14 model_configs=[ModelConfig(
15 model_id="MiniMax/MiniMax-H3",
16 origin_file_pattern="FL2VA/text_encoder/model*.safetensors",
17 offload_dtype="disk",
18 offload_device="disk",
19 onload_dtype="disk",
20 onload_device="disk",
21 preparing_dtype=torch.bfloat16,
22 preparing_device="cuda",
23 computation_dtype=torch.bfloat16,
24 computation_device="cuda",
25 )],
26 processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
27 vram_limit=0,
28)
29prompt = "xxx"
30text_embedding = pipe.export_text_embedding(prompt)
31save_file({"weight": text_embedding}, "model.safetensors")1import torch
2from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
3from diffsynth.diffusion.template import TemplatePipeline
4from diffsynth.utils.data.audio_video import write_video_audio
5from diffsynth.core.data.operators import ImageCropAndResize
6from modelscope import snapshot_download
7from PIL import Image1vram_config = {
2 "offload_dtype": "disk",
3 "offload_device": "disk",
4 "onload_dtype": "disk",
5 "onload_device": "disk",
6 "preparing_dtype": torch.bfloat16,
7 "preparing_device": "cuda",
8 "computation_dtype": torch.bfloat16,
9 "computation_device": "cuda",
10}
11pipe = MiniMaxH3Pipeline.from_pretrained(
12 torch_dtype=torch.bfloat16,
13 device="cuda",
14 model_configs=[
15 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
16 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
17 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
18 ],
19 processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
20 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
21)
22pipe.load_lora(
23 pipe.dit,
24 ModelConfig(
25 model_id="lightx2v/Minimax-h3-Turbo",
26 origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
27 ),
28)
29template = TemplatePipeline.from_pretrained(
30 torch_dtype=torch.bfloat16,
31 device="cuda",
32 model_configs=[ModelConfig(
33 model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/art_is_explosion/",
34 )],
35)
36snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
37first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
38video, audio = template(
39 pipe,
40 height=1344, width=768, num_frames=56,
41 num_inference_steps=4, seed=0, flow_shift=6,
42 keyframes=[first_frame], keyframe_indices=[0],
43 template_inputs=[{}],
44)
45write_video_audio(
46 video=video, audio=audio,
47 output_path="output.mp4", fps=24, audio_sample_rate=32000,
48)1import torch
2from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
3from diffsynth.diffusion.template import TemplatePipeline
4from diffsynth.utils.data.audio_video import write_video_audio
5from diffsynth.core.data.operators import ImageCropAndResize
6from modelscope import snapshot_download
7from PIL import Image
8
9```python
10vram_config = {
11 "offload_dtype": "disk",
12 "offload_device": "disk",
13 "onload_dtype": "disk",
14 "onload_device": "disk",
15 "preparing_dtype": torch.bfloat16,
16 "preparing_device": "cuda",
17 "computation_dtype": torch.bfloat16,
18 "computation_device": "cuda",
19}
20pipe = MiniMaxH3Pipeline.from_pretrained(
21 torch_dtype=torch.bfloat16,
22 device="cuda",
23 model_configs=[
24 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
25 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
26 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
27 ],
28 processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
29 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
30)
31pipe.load_lora(
32 pipe.dit,
33 ModelConfig(
34 model_id="lightx2v/Minimax-h3-Turbo",
35 origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
36 ),
37)
38template = TemplatePipeline.from_pretrained(
39 torch_dtype=torch.bfloat16,
40 device="cuda",
41 model_configs=[
42 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/art_is_explosion/"),
43 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings", origin_file_pattern="models/storm_magic/"),
44 ],
45)
46snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
47first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
48video, audio = template(
49 pipe,
50 height=1344, width=768, num_frames=56,
51 num_inference_steps=4, seed=0, flow_shift=6,
52 keyframes=[first_frame], keyframe_indices=[0],
53 template_inputs=[{"model_id": 0}, {"model_id": 1}],
54)
55write_video_audio(
56 video=video, audio=audio,
57 output_path="output.mp4", fps=24, audio_sample_rate=32000,
58)1import torch
2from diffsynth.pipelines.minimax_h3_audio_video import MiniMaxH3Pipeline, ModelConfig
3from diffsynth.utils.data.audio_video import write_video_audio
4from diffsynth.core.data.operators import ImageCropAndResize
5from diffsynth import load_state_dict
6from modelscope import snapshot_download
7from PIL import Image
8
9vram_config = {
10 "offload_dtype": "disk",
11 "offload_device": "disk",
12 "onload_dtype": "disk",
13 "onload_device": "disk",
14 "preparing_dtype": torch.bfloat16,
15 "preparing_device": "cuda",
16 "computation_dtype": torch.bfloat16,
17 "computation_device": "cuda",
18}
19pipe = MiniMaxH3Pipeline.from_pretrained(
20 torch_dtype=torch.bfloat16,
21 device="cuda",
22 model_configs=[
23 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="minimax-h3-fl2va-pruned-nf4.safetensors", **vram_config),
24 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="video_vae_nf4.safetensors", **vram_config),
25 ModelConfig(model_id="DiffSynth-Studio/MiniMax-H3-NF4", origin_file_pattern="audio_vae_nf4.safetensors", **vram_config),
26 ],
27 processor_config=ModelConfig(model_id="MiniMax/MiniMax-H3", origin_file_pattern="FL2VA/processor/"),
28 vram_limit=torch.cuda.mem_get_info("cuda")[1] / (1024 ** 3) - 2,
29)
30pipe.load_lora(
31 pipe.dit,
32 ModelConfig(
33 model_id="lightx2v/Minimax-h3-Turbo",
34 origin_file_pattern="minimax_h3_fl2v_turbo_4step_v1.0_768p_bf16.safetensors",
35 ),
36)
37text_embedding_config = ModelConfig(
38 model_id="DiffSynth-Studio/MiniMax-H3-Text-Embeddings",
39 origin_file_pattern="models/art_is_explosion/model.safetensors",
40)
41text_embedding_config.download_if_necessary()
42text_embedding = load_state_dict(text_embedding_config.path)["weight"]1snapshot_download("DiffSynth-Studio/MiniMax-H3-Text-Embeddings", allow_file_pattern="assets/image_1.jpg", local_dir="data")
2first_frame = ImageCropAndResize(height=1344, width=768)(Image.open("data/assets/image_1.jpg"))
3video, audio = pipe(
4 height=1344, width=768, num_frames=56,
5 num_inference_steps=4, seed=0, flow_shift=6,
6 keyframes=[first_frame], keyframe_indices=[0],
7 text_embedding=text_embedding,
8)
9write_video_audio(
10 video=video, audio=audio,
11 output_path="output.mp4", fps=24, audio_sample_rate=32000,
12)1modelscope download --dataset DiffSynth-Studio/diffsynth_example_dataset --include "minimax_h3/MiniMax-H3-Text-Embeddings/*" --local_dir ./data/diffsynth_example_dataset
2
3accelerate launch examples/minimax_h3/model_training/train.py \
4 --dataset_base_path data/diffsynth_example_dataset/minimax_h3/MiniMax-H3-Text-Embeddings \
5 --dataset_metadata_path data/diffsynth_example_dataset/minimax_h3/MiniMax-H3-Text-Embeddings/metadata.json \
6 --data_file_keys "video,input_audio" \
7 --extra_inputs "input_audio,input_image,template_inputs" \
8 --height 832 \
9 --width 480 \
10 --num_frames 124 \
11 --dataset_repeat 100 \
12 --model_id_with_origin_paths "DiffSynth-Studio/MiniMax-H3-NF4:video_vae_nf4.safetensors,DiffSynth-Studio/MiniMax-H3-NF4:audio_vae_nf4.safetensors,DiffSynth-Studio/MiniMax-H3-NF4:minimax-h3-fl2va-pruned-nf4.safetensors" \
13 --template_model_id_or_path "DiffSynth-Studio/MiniMax-H3-Text-Embeddings:models/art_is_explosion/" \
14 --learning_rate 1e-4 \
15 --num_epochs 2 \
16 --remove_prefix_in_ckpt "pipe.template_model." \
17 --output_path "./models/train/MiniMax-H3-Text-Embeddings-full" \
18 --trainable_models "template_model" \
19 --use_gradient_checkpointing