SuperCS's picture
Add files using upload-large-folder tool
2336cc9 verified

FramePack

Overview / 抂芁

This document describes the usage of the FramePack architecture within the Musubi Tuner framework. FramePack is a novel video generation architecture developed by lllyasviel.

Key differences from HunyuanVideo:

  • FramePack only supports Image-to-Video (I2V) generation. Text-to-Video (T2V) is not supported.
  • It utilizes a different DiT model architecture and requires an additional Image Encoder. VAE is same as HunyuanVideo. Text Encoders seem to be the same as HunyuanVideo but we employ the original FramePack method to utilize them.
  • Caching and training scripts are specific to FramePack (fpack_*.py).
  • Due to its progressive generation nature, VRAM usage can be significantly lower, especially for longer videos, compared to other architectures.

The official documentation does not provide detailed explanations on how to train the model, but it is based on the FramePack implementation and paper.

This feature is experimental.

For one-frame inference and training, see here.

日本語

このドキュメントは、Musubi Tunerフレヌムワヌク内でのFramePack アヌキテクチャの䜿甚法に぀いお説明しおいたす。FramePackは、lllyasviel氏にによっお開発された新しいビデオ生成アヌキテクチャです。

HunyuanVideoずの䞻な違いは次のずおりです。

  • FramePackは、画像からビデオI2V生成のみをサポヌトしおいたす。テキストからビデオT2Vはサポヌトされおいたせん。
  • 異なるDiTモデルアヌキテクチャを䜿甚し、远加の画像゚ンコヌダヌが必芁です。VAEはHunyuanVideoず同じです。テキスト゚ンコヌダヌはHunyuanVideoず同じず思われたすが、FramePack公匏ず同じ方法で掚論を行っおいたす。
  • キャッシングず孊習スクリプトはFramePack専甚fpack_*.pyです。
  • セクションず぀生成するため、他のアヌキテクチャず比范しお、特に長いビデオの堎合、VRAM䜿甚量が倧幅に少なくなる可胜性がありたす。

孊習方法に぀いお公匏からは詳现な説明はありたせんが、FramePackの実装ず論文を参考にしおいたす。

この機胜は実隓的なものです。

1フレヌム掚論、孊習に぀いおはこちらを参照しおください。

Download the model / モデルのダりンロヌド

You need to download the DiT, VAE, Text Encoder 1 (LLaMA), Text Encoder 2 (CLIP), and Image Encoder (SigLIP) models specifically for FramePack. Several download options are available for each component.

*Note: The weights are publicly available on the following page: maybleMyers/framepack_h1111 (except for FramePack-F1). Thank you maybleMyers!

DiT Model

Choose one of the following methods:

  1. From lllyasviel's Hugging Face repo: Download the three .safetensors files (starting with diffusion_pytorch_model-00001-of-00003.safetensors) from lllyasviel/FramePackI2V_HY. Specify the path to the first file (...-00001-of-00003.safetensors) as the --dit argument. For FramePack-F1, download from lllyasviel/FramePack_F1_I2V_HY_20250503.

  2. From local FramePack installation: If you have cloned and run the official FramePack repository, the model might be downloaded locally. Specify the path to the snapshot directory, e.g., path/to/FramePack/hf_download/hub/models--lllyasviel--FramePackI2V_HY/snapshots/<hex-uuid-folder>. FramePack-F1 is also available in the same way.

  3. From Kijai's Hugging Face repo: Download the single file FramePackI2V_HY_bf16.safetensors from Kijai/HunyuanVideo_comfy. Specify the path to this file as the --dit argument. No FramePack-F1 model is available here currently.

VAE Model

Choose one of the following methods:

  1. Use official HunyuanVideo VAE: Follow the instructions in the main README.md.
  2. From hunyuanvideo-community Hugging Face repo: Download vae/diffusion_pytorch_model.safetensors from hunyuanvideo-community/HunyuanVideo.
  3. From local FramePack installation: If you have cloned and run the official FramePack repository, the VAE might be downloaded locally within the HunyuanVideo community model snapshot. Specify the path to the snapshot directory, e.g., path/to/FramePack/hf_download/hub/models--hunyuanvideo-community--HunyuanVideo/snapshots/<hex-uuid-folder>.

Text Encoder 1 (LLaMA) Model

Choose one of the following methods:

  1. From Comfy-Org Hugging Face repo: Download split_files/text_encoders/llava_llama3_fp16.safetensors from Comfy-Org/HunyuanVideo_repackaged.
  2. From hunyuanvideo-community Hugging Face repo: Download the four .safetensors files (starting with text_encoder/model-00001-of-00004.safetensors) from hunyuanvideo-community/HunyuanVideo. Specify the path to the first file (...-00001-of-00004.safetensors) as the --text_encoder1 argument.
  3. From local FramePack installation: (Same as VAE) Specify the path to the HunyuanVideo community model snapshot directory, e.g., path/to/FramePack/hf_download/hub/models--hunyuanvideo-community--HunyuanVideo/snapshots/<hex-uuid-folder>.

Text Encoder 2 (CLIP) Model

Choose one of the following methods:

  1. From Comfy-Org Hugging Face repo: Download split_files/text_encoders/clip_l.safetensors from Comfy-Org/HunyuanVideo_repackaged.
  2. From hunyuanvideo-community Hugging Face repo: Download text_encoder_2/model.safetensors from hunyuanvideo-community/HunyuanVideo.
  3. From local FramePack installation: (Same as VAE) Specify the path to the HunyuanVideo community model snapshot directory, e.g., path/to/FramePack/hf_download/hub/models--hunyuanvideo-community--HunyuanVideo/snapshots/<hex-uuid-folder>.

Image Encoder (SigLIP) Model

Choose one of the following methods:

  1. From Comfy-Org Hugging Face repo: Download sigclip_vision_patch14_384.safetensors from Comfy-Org/sigclip_vision_384.
  2. From lllyasviel's Hugging Face repo: Download image_encoder/model.safetensors from lllyasviel/flux_redux_bfl.
  3. From local FramePack installation: If you have cloned and run the official FramePack repository, the model might be downloaded locally. Specify the path to the snapshot directory, e.g., path/to/FramePack/hf_download/hub/models--lllyasviel--flux_redux_bfl/snapshots/<hex-uuid-folder>.
日本語

※以䞋のペヌゞに重みが䞀括で公開されおいたすFramePack-F1を陀く。maybleMyers 氏に感謝いたしたす。: https://huggingface.co/maybleMyers/framepack_h1111

DiT、VAE、テキスト゚ンコヌダヌ1LLaMA、テキスト゚ンコヌダヌ2CLIP、および画像゚ンコヌダヌSigLIPモデルは耇数の方法でダりンロヌドできたす。英語の説明を参考にしお、ダりンロヌドしおください。

FramePack公匏のリポゞトリをクロヌンしお実行した堎合、モデルはロヌカルにダりンロヌドされおいる可胜性がありたす。スナップショットディレクトリぞのパスを指定しおください。䟋path/to/FramePack/hf_download/hub/models--lllyasviel--flux_redux_bfl/snapshots/<hex-uuid-folder>

HunyuanVideoの掚論をComfyUIですでに行っおいる堎合、いく぀かのモデルはすでにダりンロヌドされおいる可胜性がありたす。

Pre-caching / 事前キャッシング

The default resolution for FramePack is 640x640. See the source code for the default resolution of each bucket.

The dataset for training must be a video dataset. Image datasets are not supported. You can train on videos of any length. Specify frame_extraction as full and set max_frames to a sufficiently large value. However, if the video is too long, you may run out of VRAM during VAE encoding.

Latent Pre-caching / latentの事前キャッシング

Latent pre-caching uses a dedicated script for FramePack. You must provide the Image Encoder model.

python src/musubi_tuner/fpack_cache_latents.py \
    --dataset_config path/to/toml \
    --vae path/to/vae_model.safetensors \
    --image_encoder path/to/image_encoder_model.safetensors \
    --vae_chunk_size 32 --vae_spatial_tile_sample_min_size 128 

Key differences from HunyuanVideo caching:

  • Uses fpack_cache_latents.py.
  • Requires the --image_encoder argument pointing to the downloaded SigLIP model.
  • The script generates multiple cache files per video, each corresponding to a different section, with the section index appended to the filename (e.g., ..._frame_pos-0000-count_... becomes ..._frame_pos-0000-0000-count_..., ..._frame_pos-0000-0001-count_..., etc.).
  • Image embeddings are calculated using the Image Encoder and stored in the cache files alongside the latents.

For VRAM savings during VAE decoding, consider using --vae_chunk_size and --vae_spatial_tile_sample_min_size. If VRAM is overflowing and using shared memory, it is recommended to set --vae_chunk_size to 16 or 8, and --vae_spatial_tile_sample_min_size to 64 or 32.

Specifying --f1 is required for FramePack-F1 training. For one-frame training, specify --one_frame. If you change the presence of these options, please overwrite the existing cache without specifying --skip_existing.

--one_frame_no_2x and --one_frame_no_4x options are available for one-frame training, described in the next section.

FramePack-F1 support: You can apply the FramePack-F1 sampling method by specifying --f1 during caching. The training script also requires specifying --f1 to change the options during sample generation.

By default, the sampling method used is Inverted anti-drifting (the same as during inference with the original FramePack model, using the latent and index in reverse order), described in the paper. You can switch to FramePack-F1 sampling (Vanilla sampling, using the temporally ordered latent and index) by specifying --f1.

日本語

FramePackのデフォルト解像床は640x640です。各バケットのデフォルト解像床に぀いおは、゜ヌスコヌドを参照しおください。

画像デヌタセットでの孊習は行えたせん。たた動画の長さによらず孊習可胜です。 frame_extraction に full を指定しお、max_frames に十分に倧きな倀を指定しおください。ただし、あたりにも長いずVAEのencodeでVRAMが䞍足する可胜性がありたす。

latentの事前キャッシングはFramePack専甚のスクリプトを䜿甚したす。画像゚ンコヌダヌモデルを指定する必芁がありたす。

HunyuanVideoのキャッシングずの䞻な違いは次のずおりです。

  • fpack_cache_latents.pyを䜿甚したす。
  • ダりンロヌドしたSigLIPモデルを指す--image_encoder匕数が必芁です。
  • スクリプトは、各ビデオに察しお耇数のキャッシュファむルを生成したす。各ファむルは異なるセクションに察応し、セクションむンデックスがファむル名に远加されたす䟋..._frame_pos-0000-count_...は..._frame_pos-0000-0000-count_...、..._frame_pos-0000-0001-count_...などになりたす。
  • 画像埋め蟌みは画像゚ンコヌダヌを䜿甚しお蚈算され、latentずずもにキャッシュファむルに保存されたす。

VAEのdecode時のVRAM節玄のために、--vae_chunk_sizeず--vae_spatial_tile_sample_min_sizeを䜿甚するこずを怜蚎しおください。VRAMがあふれお共有メモリを䜿甚しおいる堎合には、--vae_chunk_sizeを16、8などに、--vae_spatial_tile_sample_min_sizeを64、32などに倉曎するこずをお勧めしたす。

FramePack-F1の孊習を行う堎合は--f1を指定しおください。これらのオプションの有無を倉曎する堎合には、--skip_existingを指定せずに既存のキャッシュを䞊曞きしおください。

FramePack-F1のサポヌト キャッシュ時のオプションに--f1を指定するこずで、FramePack-F1のサンプリング方法を適甚できたす。孊習スクリプトに぀いおも--f1を指定しおサンプル生成時のオプションを倉曎する必芁がありたす。

デフォルトでは、論文のサンプリング方法 Inverted anti-drifting 無印のFramePackの掚論時ず同じ、逆順の latent ず index を䜿甚を䜿甚したす。--f1を指定するず FramePack-F1 の Vanilla sampling 時間順の latent ず index を䜿甚に倉曎できたす。

Text Encoder Output Pre-caching / テキスト゚ンコヌダヌ出力の事前キャッシング

Text encoder output pre-caching also uses a dedicated script.

python src/musubi_tuner/fpack_cache_text_encoder_outputs.py \
    --dataset_config path/to/toml \
    --text_encoder1 path/to/text_encoder1 \
    --text_encoder2 path/to/text_encoder2 \
    --batch_size 16

Key differences from HunyuanVideo caching:

  • Uses fpack_cache_text_encoder_outputs.py.
  • Requires both --text_encoder1 (LLaMA) and --text_encoder2 (CLIP) arguments.
  • Uses --fp8_llm option to run the LLaMA Text Encoder 1 in fp8 mode for VRAM savings (similar to --fp8_t5 in Wan2.1).
  • Saves LLaMA embeddings, attention mask, and CLIP pooler output to the cache file.
日本語

テキスト゚ンコヌダヌ出力の事前キャッシングも専甚のスクリプトを䜿甚したす。

HunyuanVideoのキャッシングずの䞻な違いは次のずおりです。

  • fpack_cache_text_encoder_outputs.pyを䜿甚したす。
  • LLaMAずCLIPの䞡方の匕数が必芁です。
  • LLaMAテキスト゚ンコヌダヌ1をfp8モヌドで実行するための--fp8_llmオプションを䜿甚したすWan2.1の--fp8_t5に䌌おいたす。
  • LLaMAの埋め蟌み、アテンションマスク、CLIPのプヌラヌ出力をキャッシュファむルに保存したす。

Training / å­Šç¿’

Training

Training uses a dedicated script fpack_train_network.py. Remember FramePack only supports I2V training.

accelerate launch --num_cpu_threads_per_process 1 --mixed_precision bf16 src/musubi_tuner/fpack_train_network.py \
    --dit path/to/dit_model \
    --vae path/to/vae_model.safetensors \
    --text_encoder1 path/to/text_encoder1 \
    --text_encoder2 path/to/text_encoder2 \
    --image_encoder path/to/image_encoder_model.safetensors \
    --dataset_config path/to/toml \
    --sdpa --mixed_precision bf16 \
    --optimizer_type adamw8bit --learning_rate 2e-4 --gradient_checkpointing \
    --timestep_sampling shift --weighting_scheme none --discrete_flow_shift 3.0 \
    --max_data_loader_n_workers 2 --persistent_data_loader_workers \
    --network_module networks.lora_framepack --network_dim 32 \
    --max_train_epochs 16 --save_every_n_epochs 1 --seed 42 \
    --output_dir path/to/output_dir --output_name name-of-lora

If you use the command prompt (Windows, not PowerShell), you may need to write them in a single line, or use ^ instead of \ at the end of each line to continue the command.

The maximum value for --blocks_to_swap is 36. The default resolution for FramePack is 640x640, which requires around 17GB of VRAM. If you run out of VRAM, consider lowering the dataset resolution.

Key differences from HunyuanVideo training:

  • Uses fpack_train_network.py.
  • --f1 option is available for FramePack-F1 model training. You need to specify the FramePack-F1 model as --dit. This option only changes the sample generation during training. The training process itself is the same as the original FramePack model.
  • Requires specifying --vae, --text_encoder1, --text_encoder2, and --image_encoder.
  • Requires specifying --network_module networks.lora_framepack.
  • Optional --latent_window_size argument (default 9, should match caching).
  • Memory saving options like --fp8 (for DiT) and --fp8_llm (for Text Encoder 1) are available. --fp8_scaled is recommended when using --fp8 for DiT.
  • --vae_chunk_size and --vae_spatial_tile_sample_min_size options are available for the VAE to prevent out-of-memory during sampling (similar to caching).
  • --gradient_checkpointing is available for memory savings.
  • If you encounter an error when the batch size is greater than 1 (especially when specifying --sdpa or --xformers, it will always result in an error), please specify --split_attn.

Training settings (learning rate, optimizers, etc.) are experimental. Feedback is welcome.

日本語

FramePackの孊習は専甚のスクリプトfpack_train_network.pyを䜿甚したす。FramePackはI2V孊習のみをサポヌトしおいたす。

コマンド蚘述䟋は英語版を参考にしおください。WindowsでPowerShellではなくコマンドプロンプトを䜿甚しおいる堎合、コマンドを1行で蚘述するか、各行の末尟に\の代わりに^を付けおコマンドを続ける必芁がありたす。

--blocks_to_swapの最倧倀は36です。FramePackのデフォルト解像床640x640では、17GB皋床のVRAMが必芁です。VRAM容量が䞍足する堎合は、デヌタセットの解像床を䞋げおください。

HunyuanVideoの孊習ずの䞻な違いは次のずおりです。

  • fpack_train_network.pyを䜿甚したす。
  • FramePack-F1モデルの孊習時には--f1を指定しおください。この堎合、--ditにFramePack-F1モデルを指定する必芁がありたす。このオプションは孊習時のサンプル生成時のみに圱響し、孊習プロセス自䜓は元のFramePackモデルず同じです。
  • --vae、--text_encoder1、--text_encoder2、--image_encoderを指定する必芁がありたす。
  • --network_module networks.lora_framepackを指定する必芁がありたす。
  • 必芁に応じお--latent_window_size匕数デフォルト9を指定できたすキャッシング時ず䞀臎させる必芁がありたす。
  • --fp8DiT甚や--fp8_llmテキスト゚ンコヌダヌ1甚などのメモリ節玄オプションが利甚可胜です。--fp8_scaledを䜿甚するこずをお勧めしたす。
  • サンプル生成時にメモリ䞍足を防ぐため、VAE甚の--vae_chunk_size、--vae_spatial_tile_sample_min_sizeオプションが利甚可胜ですキャッシング時ず同様。
  • メモリ節玄のために--gradient_checkpointingが利甚可胜です。
  • バッチサむズが1より倧きい堎合に゚ラヌが出た時には特に--sdpaや--xformersを指定するず必ず゚ラヌになりたす。、--split_attnを指定しおください。

Inference

Inference uses a dedicated script fpack_generate_video.py.

python src/musubi_tuner/fpack_generate_video.py \
    --dit path/to/dit_model \
    --vae path/to/vae_model.safetensors \
    --text_encoder1 path/to/text_encoder1 \
    --text_encoder2 path/to/text_encoder2 \
    --image_encoder path/to/image_encoder_model.safetensors \
    --image_path path/to/start_image.jpg \
    --prompt "A cat walks on the grass, realistic style." \
    --video_size 512 768 --video_seconds 5 --fps 30 --infer_steps 25 \
    --attn_mode sdpa --fp8_scaled \
    --vae_chunk_size 32 --vae_spatial_tile_sample_min_size 128 \
    --save_path path/to/save/dir --output_type both \
    --seed 1234 --lora_multiplier 1.0 --lora_weight path/to/lora.safetensors

Key differences from HunyuanVideo inference:

  • Uses fpack_generate_video.py.
  • --f1 option is available for FramePack-F1 model inference (forward generation). You need to specify the FramePack-F1 model as --dit.
  • Requires specifying --vae, --text_encoder1, --text_encoder2, and --image_encoder.
  • Requires specifying --image_path for the starting frame.
  • Requires specifying --video_seconds or --video_sections. --video_seconds specifies the length of the video in seconds, while --video_sections specifies the number of sections. If --video_sections is specified, --video_seconds is ignored.
  • --video_size is the size of the generated video, height and width are specified in that order.
  • --prompt: Prompt for generation.
  • Optional --latent_window_size argument (default 9, should match caching and training).
  • --fp8_scaled option is available for DiT to reduce memory usage. Quality may be slightly lower. --fp8_llm option is available to reduce memory usage of Text Encoder 1. --fp8 alone is also an option for DiT but --fp8_scaled potentially offers better quality.
  • LoRA loading options (--lora_weight, --lora_multiplier, --include_patterns, --exclude_patterns) are available. --lycoris is also supported.
  • --embedded_cfg_scale (default 10.0) controls the distilled guidance scale.
  • --guidance_scale (default 1.0) controls the standard classifier-free guidance scale. Changing this from 1.0 is generally not recommended for the base FramePack model.
  • --guidance_rescale (default 0.0) is available but typically not needed.
  • --bulk_decode option can decode all frames at once, potentially faster but uses more VRAM during decoding. --vae_chunk_size and --vae_spatial_tile_sample_min_size options are recommended to prevent out-of-memory errors.
  • --sample_solver (default unipc) is available but only unipc is implemented.
  • --save_merged_model option is available to save the DiT model after merging LoRA weights. Inference is skipped if this is specified.
  • --latent_paddings option overrides the default padding for each section. Specify it as a comma-separated list of integers, e.g., --latent_paddings 0,0,0,0. This option is ignored if --f1 is specified.
  • --custom_system_prompt option overrides the default system prompt for the LLaMA Text Encoder 1. Specify it as a string. See here for the default system prompt.
  • --rope_scaling_timestep_threshold option is the RoPE scaling timestep threshold, default is None (disabled). If set, RoPE scaling is applied only when the timestep exceeds the threshold. Start with around 800 and adjust as needed. This option is intended for one-frame inference and may not be suitable for other cases.
  • --rope_scaling_factor option is the RoPE scaling factor, default is 0.5, assuming a resolution of 2x. For 1.5x resolution, around 0.7 is recommended.

Other options like --video_size, --fps, --infer_steps, --save_path, --output_type, --seed, --attn_mode, --blocks_to_swap, --vae_chunk_size, --vae_spatial_tile_sample_min_size function similarly to HunyuanVideo/Wan2.1 where applicable.

--output_type supports latent_images in addition to the options available in HunyuanVideo/Wan2.1. This option saves the latent and image files in the specified directory.

The LoRA weights that can be specified in --lora_weight are not limited to the FramePack weights trained in this repository. You can also specify the HunyuanVideo LoRA weights from this repository and the HunyuanVideo LoRA weights from diffusion-pipe (automatic detection).

The maximum value for --blocks_to_swap is 38.

日本語

FramePackの掚論は専甚のスクリプトfpack_generate_video.pyを䜿甚したす。コマンド蚘述䟋は英語版を参考にしおください。

HunyuanVideoの掚論ずの䞻な違いは次のずおりです。

  • fpack_generate_video.pyを䜿甚したす。
  • --f1を指定するず、FramePack-F1モデルの掚論を行いたす順方向で生成。--ditにFramePack-F1モデルを指定する必芁がありたす。
  • --vae、--text_encoder1、--text_encoder2、--image_encoderを指定する必芁がありたす。
  • --image_pathを指定する必芁がありたす開始フレヌム。
  • --video_seconds たたは --video_sections を指定する必芁がありたす。--video_secondsは秒単䜍でのビデオの長さを指定し、--video_sectionsはセクション数を指定したす。--video_sectionsを指定した堎合、--video_secondsは無芖されたす。
  • --video_sizeは生成するビデオのサむズで、高さず幅をその順番で指定したす。
  • --prompt: 生成甚のプロンプトです。
  • 必芁に応じお--latent_window_size匕数デフォルト9を指定できたすキャッシング時、孊習時ず䞀臎させる必芁がありたす。
  • DiTのメモリ䜿甚量を削枛するために、--fp8_scaledオプションを指定可胜です。品質はやや䜎䞋する可胜性がありたす。たたText Encoder 1のメモリ䜿甚量を削枛するために、--fp8_llmオプションを指定可胜です。DiT甚に--fp8単独のオプションも甚意されおいたすが、--fp8_scaledの方が品質が良い可胜性がありたす。
  • LoRAの読み蟌みオプション--lora_weight、--lora_multiplier、--include_patterns、--exclude_patternsが利甚可胜です。LyCORISもサポヌトされおいたす。
  • --embedded_cfg_scaleデフォルト10.0は、蒞留されたガむダンススケヌルを制埡したす。通垞は倉曎しないでください。
  • --guidance_scaleデフォルト1.0は、暙準の分類噚フリヌガむダンススケヌルを制埡したす。FramePackモデルのベヌスモデルでは、通垞1.0から倉曎しないこずをお勧めしたす。
  • --guidance_rescaleデフォルト0.0も利甚可胜ですが、通垞は必芁ありたせん。
  • --bulk_decodeオプションは、すべおのフレヌムを䞀床にデコヌドできるオプションです。高速ですが、デコヌド䞭にVRAMを倚く䜿甚したす。VRAM䞍足゚ラヌを防ぐために、--vae_chunk_sizeず--vae_spatial_tile_sample_min_sizeオプションを指定するこずをお勧めしたす。
  • --sample_solverデフォルトunipcは利甚可胜ですが、unipcのみが実装されおいたす。
  • --save_merged_modelオプションは、LoRAの重みをマヌゞした埌にDiTモデルを保存するためのオプションです。これを指定するず掚論はスキップされたす。
  • --latent_paddingsオプションは、各セクションのデフォルトのパディングを䞊曞きしたす。カンマ区切りの敎数リストずしお指定したす。䟋--latent_paddings 0,0,0,0。--f1を指定した堎合は無芖されたす。
  • --custom_system_promptオプションは、LLaMA Text Encoder 1のデフォルトのシステムプロンプトを䞊曞きしたす。文字列ずしお指定したす。デフォルトのシステムプロンプトはこちらを参照しおください。
  • --rope_scaling_timestep_thresholdオプションはRoPEスケヌリングのタむムステップ閟倀で、デフォルトはNone無効です。蚭定するず、タむムステップが閟倀以䞊の堎合にのみRoPEスケヌリングが適甚されたす。800皋床から初めお調敎しおください。1フレヌム掚論時での䜿甚を想定しおおり、それ以倖の堎合は想定しおいたせん。
  • --rope_scaling_factorオプションはRoPEスケヌリング係数で、デフォルトは0.5で、解像床が2倍の堎合を想定しおいたす。1.5倍なら0.7皋床が良いでしょう。

--video_size、--fps、--infer_steps、--save_path、--output_type、--seed、--attn_mode、--blocks_to_swap、--vae_chunk_size、--vae_spatial_tile_sample_min_sizeなどの他のオプションは、HunyuanVideo/Wan2.1ず同様に機胜したす。

--lora_weightに指定できるLoRAの重みは、圓リポゞトリで孊習したFramePackの重み以倖に、圓リポゞトリのHunyuanVideoのLoRA、diffusion-pipeのHunyuanVideoのLoRAが指定可胜です自動刀定。

--blocks_to_swapの最倧倀は38です。

Batch and Interactive Modes / バッチモヌドずむンタラクティブモヌド

In addition to single video generation, FramePack now supports batch generation from file and interactive prompt input:

Batch Mode from File / ファむルからのバッチモヌド

Generate multiple videos from prompts stored in a text file:

python src/musubi_tuner/fpack_generate_video.py --from_file prompts.txt 
--dit path/to/dit_model --vae path/to/vae_model.safetensors 
--text_encoder1 path/to/text_encoder1 --text_encoder2 path/to/text_encoder2 
--image_encoder path/to/image_encoder_model.safetensors --save_path output_directory

The prompts file format:

  • One prompt per line
  • Empty lines and lines starting with # are ignored (comments)
  • Each line can include prompt-specific parameters using command-line style format:
A beautiful sunset over mountains --w 832 --h 480 --f 5 --d 42 --s 20 --i path/to/start_image.jpg
A busy city street at night --w 480 --h 832 --i path/to/another_start.jpg

Supported inline parameters (if omitted, default values from the command line are used):

  • --w: Width
  • --h: Height
  • --f: Video seconds
  • --d: Seed
  • --s: Inference steps
  • --g or --l: Guidance scale
  • --i: Image path (for start image)
  • --im: Image mask path
  • --n: Negative prompt
  • --vs: Video sections
  • --ei: End image path
  • --ci: Control image path (explained in one-frame inference documentation)
  • --cim: Control image mask path (explained in one-frame inference documentation)
  • --of: One frame inference mode options (same as --one_frame_inference in the command line), options for one-frame inference

In batch mode, models are loaded once and reused for all prompts, significantly improving overall generation time compared to multiple single runs.

Interactive Mode / むンタラクティブモヌド

Interactive command-line interface for entering prompts:

python src/musubi_tuner/fpack_generate_video.py --interactive
--dit path/to/dit_model --vae path/to/vae_model.safetensors 
--text_encoder1 path/to/text_encoder1 --text_encoder2 path/to/text_encoder2 
--image_encoder path/to/image_encoder_model.safetensors --save_path output_directory

In interactive mode:

  • Enter prompts directly at the command line
  • Use the same inline parameter format as batch mode
  • Use Ctrl+D (or Ctrl+Z on Windows) to exit
  • Models remain loaded between generations for efficiency
日本語

単䞀動画の生成に加えお、FramePackは珟圚、ファむルからのバッチ生成ずむンタラクティブなプロンプト入力をサポヌトしおいたす。

ファむルからのバッチモヌド

テキストファむルに保存されたプロンプトから耇数の動画を生成したす

python src/musubi_tuner/fpack_generate_video.py --from_file prompts.txt 
--dit path/to/dit_model --vae path/to/vae_model.safetensors 
--text_encoder1 path/to/text_encoder1 --text_encoder2 path/to/text_encoder2 
--image_encoder path/to/image_encoder_model.safetensors --save_path output_directory

プロンプトファむルの圢匏サンプルは英語ドキュメントを参照

  • 1行に1぀のプロンプト
  • 空行や#で始たる行は無芖されたすコメント
  • 各行にはコマンドラむン圢匏でプロンプト固有のパラメヌタを含めるこずができたす

サポヌトされおいるむンラむンパラメヌタ省略した堎合、コマンドラむンのデフォルト倀が䜿甚されたす

  • --w: 幅
  • --h: 高さ
  • --f: 動画の秒数
  • --d: シヌド
  • --s: 掚論ステップ
  • --g たたは --l: ガむダンススケヌル
  • --i: 画像パス開始画像甚
  • --im: 画像マスクパス
  • --n: ネガティブプロンプト
  • --vs: 動画セクション数
  • --ei: 終了画像パス
  • --ci: 制埡画像パス1フレヌム掚論のドキュメントで解説
  • --cim: 制埡画像マスクパス1フレヌム掚論のドキュメントで解説
  • --of: 1フレヌム掚論モヌドオプションコマンドラむンの--one_frame_inferenceず同様、1フレヌム掚論のオプション

バッチモヌドでは、モデルは䞀床だけロヌドされ、すべおのプロンプトで再利甚されるため、耇数回の単䞀実行ず比范しお党䜓的な生成時間が倧幅に改善されたす。

むンタラクティブモヌド

プロンプトを入力するためのむンタラクティブなコマンドラむンむンタヌフェヌス

python src/musubi_tuner/fpack_generate_video.py --interactive
--dit path/to/dit_model --vae path/to/vae_model.safetensors 
--text_encoder1 path/to/text_encoder1 --text_encoder2 path/to/text_encoder2 
--image_encoder path/to/image_encoder_model.safetensors --save_path output_directory

むンタラクティブモヌドでは

  • コマンドラむンで盎接プロンプトを入力
  • バッチモヌドず同じむンラむンパラメヌタ圢匏を䜿甚
  • 終了するには Ctrl+D (Windowsでは Ctrl+Z) を䜿甚
  • 効率のため、モデルは生成間で読み蟌たれたたたになりたす

Advanced Video Control Features (Experimental) / 高床なビデオ制埡機胜実隓的

This section describes experimental features added to the fpack_generate_video.py script to provide finer control over the generated video content, particularly useful for longer videos or sequences requiring specific transitions or states. These features leverage the Inverted Anti-drifting sampling method inherent to FramePack.

1. End Image Guidance (--end_image_path)

  • Functionality: Guides the generation process to make the final frame(s) of the video resemble a specified target image.
  • Usage: --end_image_path <path_to_image_file>
  • Mechanism: The provided image is encoded using the VAE. This latent representation is used as a target or starting point during the generation of the final video section (which is the first step in Inverted Anti-drifting).
  • Use Cases: Defining a clear ending for the video, such as a character striking a specific pose or a product appearing in a close-up.

This option is ignored if --f1 is specified. The end image is not used in the FramePack-F1 model.

2. Section Start Image Guidance (--image_path Extended Format)

  • Functionality: Guides specific sections within the video to start with a visual state close to a provided image.
    • You can force the start image by setting --latent_paddings to 0,0,0,0 (specify the number of sections as a comma-separated list). If latent_paddings is set to 1 or more, the specified image will be used as a reference image (default behavior).
  • Usage: --image_path "SECTION_SPEC:path/to/image.jpg;;;SECTION_SPEC:path/to/another.jpg;;;..."
    • SECTION_SPEC: Defines the target section(s). Rules:
      • 0: The first section of the video (generated last in Inverted Anti-drifting).
      • -1: The last section of the video (generated first).
      • N (non-negative integer): The N-th section (0-indexed).
      • -N (negative integer): The N-th section from the end.
      • S-E (range, e.g., 0-2): Applies the same image guidance to sections S through E (inclusive).
    • Use ;;; as a separator between definitions.
    • If no image is specified for a section, generation proceeds based on the prompt and preceding (future time) section context.
  • Mechanism: When generating a specific section, if a corresponding start image is provided, its VAE latent representation is strongly referenced as the "initial state" for that section. This guides the beginning of the section towards the specified image while attempting to maintain temporal consistency with the subsequent (already generated) section.
  • Use Cases: Defining clear starting points for scene changes, specifying character poses or attire at the beginning of certain sections.

3. Section-Specific Prompts (--prompt Extended Format)

  • Functionality: Allows providing different text prompts for different sections of the video, enabling more granular control over the narrative or action flow.
  • Usage: --prompt "SECTION_SPEC:Prompt text for section(s);;;SECTION_SPEC:Another prompt;;;..."
    • SECTION_SPEC: Uses the same rules as --image_path.
    • Use ;;; as a separator.
    • If a prompt for a specific section is not provided, the prompt associated with index 0 (or the closest specified applicable prompt) is typically used. Check behavior if defaults are critical.
  • Mechanism: During the generation of each section, the corresponding section-specific prompt is used as the primary textual guidance for the model.
  • Prompt Content Recommendation when using --latent_paddings 0,0,0,0 without --f1 (original FramePack model):
    • Recall that FramePack uses Inverted Anti-drifting and references future context.
    • It is recommended to describe "the main content or state change that should occur in the current section, and the subsequent events or states leading towards the end of the video" in the prompt for each section.
    • Including the content of subsequent sections in the current section's prompt helps the model maintain context and overall coherence.
    • Example: For section 1, the prompt might describe what happens in section 1 and briefly summarize section 2 (and beyond).
    • However, based on observations (e.g., the latent_paddings comment), the model's ability to perfectly utilize very long-term context might be limited. Experimentation is key. Describing just the "goal for the current section" might also work. Start by trying the "section and onwards" approach.
  • Use the default prompt when latent_paddings is >= 1 or --latent_paddings is not specified, or when using --f1 (FramePack-F1 model).
  • Use Cases: Describing evolving storylines, gradual changes in character actions or emotions, step-by-step processes over time.

Combined Usage Example (with --f1 not specified)

Generating a 3-section video of "A dog runs towards a thrown ball, catches it, and runs back":

python src/musubi_tuner/fpack_generate_video.py \
 --prompt "0:A dog runs towards a thrown ball, catches it, and runs back;;;1:The dog catches the ball and then runs back towards the viewer;;;2:The dog runs back towards the viewer holding the ball" \
 --image_path "0:./img_start_running.png;;;1:./img_catching.png;;;2:./img_running_back.png" \
 --end_image_path ./img_returned.png \
 --save_path ./output \
 # ... other arguments
  • Generation Order: Section 2 -> Section 1 -> Section 0
  • Generating Section 2:
    • Prompt: "The dog runs back towards the viewer holding the ball"
    • Start Image: ./img_running_back.png
    • End Image: ./img_returned.png (Initial target)
  • Generating Section 1:
    • Prompt: "The dog catches the ball and then runs back towards the viewer"
    • Start Image: ./img_catching.png
    • Future Context: Generated Section 2 latent
  • Generating Section 0:
    • Prompt: "A dog runs towards a thrown ball, catches it, and runs back"
    • Start Image: ./img_start_running.png
    • Future Context: Generated Section 1 & 2 latents

Important Considerations

  • Inverted Generation: Always remember that generation proceeds from the end of the video towards the beginning. Section -1 (the last section, 2 in the example) is generated first.
  • Continuity vs. Guidance: While start image guidance is powerful, drastically different images between sections might lead to unnatural transitions. Balance guidance strength with the need for smooth flow.
  • Prompt Optimization: The prompt content recommendation is a starting point. Fine-tune prompts based on observed model behavior and desired output quality.
日本語

高床な動画制埡機胜実隓的

このセクションでは、fpack_generate_video.py スクリプトに远加された実隓的な機胜に぀いお説明したす。これらの機胜は、生成される動画の内容をより詳现に制埡するためのもので、特に長い動画や特定の遷移・状態が必芁なシヌケンスに圹立ちたす。これらの機胜は、FramePack固有のInverted Anti-driftingサンプリング方匏を掻甚しおいたす。

1. 終端画像ガむダンス (--end_image_path)

  • 機胜: 動画の最埌のフレヌム矀を指定したタヌゲット画像に近づけるように生成を誘導したす。
  • 曞匏: --end_image_path <画像ファむルパス>
  • 動䜜: 指定された画像はVAEで゚ンコヌドされ、その朜圚衚珟が動画の最終セクションInverted Anti-driftingでは最初に生成されるの生成時の目暙たたは開始点ずしお䜿甚されたす。
  • 甹途: キャラクタヌが特定のポヌズで終わる、特定の商品がクロヌズアップで終わるなど、動画の結末を明確に定矩する堎合。

このオプションは、--f1を指定した堎合は無芖されたす。FramePack-F1モデルでは終端画像は䜿甚されたせん。

2. セクション開始画像ガむダンス (--image_path 拡匵曞匏)

  • 機胜: 動画内の特定のセクションが、指定された画像に近い芖芚状態から始たるように誘導したす。
    • --latent_paddingsを0,0,0,0カンマ区切りでセクション数だけ指定に蚭定するこずで、セクションの開始画像を匷制できたす。latent_paddingsが1以䞊の堎合、指定された画像は参照画像ずしお䜿甚されたす。
  • 曞匏: --image_path "セクション指定子:画像パス;;;セクション指定子:別の画像パス;;;..."
    • セクション指定子: 察象セクションを定矩したす。ルヌル
      • 0: 動画の最初のセクションInverted Anti-driftingでは最埌に生成。
      • -1: 動画の最埌のセクション最初に生成。
      • N非負敎数: N番目のセクション0始たり。
      • -N負敎数: 最埌からN番目のセクション。
      • S-E範囲, 䟋:0-2: セクションSからE䞡端含むに同じ画像を適甚。
    • 区切り文字は ;;; です。
    • セクションに画像が指定されおいない堎合、プロンプトず埌続未来時刻セクションのコンテキストに基づいお生成されたす。
  • 動䜜: 特定セクションの生成時、察応する開始画像が指定されおいれば、そのVAE朜圚衚珟がそのセクションの「初期状態」ずしお匷く参照されたす。これにより、埌続生成枈みセクションずの時間的連続性を維持しようずし぀぀、セクションの始たりを指定画像に近づけたす。
  • 甹途: シヌン倉曎の起点を明確にする、特定のセクション開始時のキャラクタヌのポヌズや服装を指定するなど。

3. セクション別プロンプト (--prompt 拡匵曞匏)

  • 機胜: 動画のセクションごずに異なるテキストプロンプトを䞎え、物語やアクションの流れをより现かく指瀺できたす。
  • 曞匏: --prompt "セクション指定子:プロンプトテキスト;;;セクション指定子:別のプロンプト;;;..."
    • セクション指定子: --image_path ず同じルヌルです。
    • 区切り文字は ;;; です。
    • 特定セクションのプロンプトがない堎合、通垞はむンデックス0に関連付けられたプロンプトたたは最も近い適甚可胜な指定プロンプトが䜿甚されたす。デフォルトの挙動が重芁な堎合は確認しおください。
  • 動䜜: 各セクションの生成時、察応するセクション別プロンプトがモデルぞの䞻芁なテキスト指瀺ずしお䜿甚されたす。
  • latent_paddingsに0を指定した堎合非F1モデルの プロンプト内容の掚奚:
    • FramePackはInverted Anti-driftingを採甚し、未来のコンテキストを参照するこずを思い出しおください。
    • 各セクションのプロンプトには、「珟圚のセクションで起こるべき䞻芁な内容や状態倉化、およびそれに続く動画の終端たでの内容」を蚘述するこずを掚奚したす。
    • 珟圚のセクションのプロンプトに埌続セクションの内容を含めるこずで、モデルが党䜓的な文脈を把握し、䞀貫性を保぀のに圹立ちたす。
    • 䟋セクション1のプロンプトには、セクション1の内容 ず セクション2の簡単な芁玄を蚘述したす。
    • ただし、モデルの長期コンテキスト完党利甚胜力には限界がある可胜性も瀺唆されおいたす䟋latent_paddingsコメント。実隓が鍵ずなりたす。「珟圚のセクションの目暙」のみを蚘述するだけでも機胜する堎合がありたす。たずは「セクションず以降」アプロヌチを詊すこずをお勧めしたす。
  • 䜿甚するプロンプトは、latent_paddingsが1以䞊たたは指定されおいない堎合、たたは--f1FramePack-F1モデルを䜿甚しおいる堎合は、通垞のプロンプト内容を蚘述しおください。
  • 甹途: 時間経過に䌎うストヌリヌの倉化、キャラクタヌの行動や感情の段階的な倉化、段階的なプロセスなどを蚘述する堎合。

組み合わせ䜿甚䟋 --f1未指定時

「投げられたボヌルに向かっお犬が走り、それを捕たえ、走っお戻っおくる」3セクション動画の生成 コマンド蚘述䟋は英語版を参考にしおください

  • 生成順序: セクション2 → セクション1 → セクション0
  • セクション2生成時:
    • プロンプト: "犬がボヌルを咥えおこちらに向かっお走っおくる"
    • 開始画像: ./img_running_back.png
    • 終端画像: ./img_returned.png 初期目暙
  • セクション1生成時:
    • プロンプト: "犬がボヌルを捕たえ、その埌こちらに向かっお走っおくる"
    • 開始画像: ./img_catching.png
    • 未来コンテキスト: 生成枈みセクション2の朜圚衚珟
  • セクション0生成時:
    • プロンプト: "犬が投げられたボヌルに向かっお走り、それを捕たえ、走っお戻っおくる"
    • 開始画像: ./img_start_running.png
    • 未来コンテキスト: 生成枈みセクション1 & 2の朜圚衚珟

重芁な考慮事項

  • 逆順生成: 生成は動画の終わりから始たりに向かっお進むこずを垞に意識しおください。セクション-1最埌のセクション、䞊の䟋では 2が最初に生成されたす。
  • 連続性ずガむダンスのバランス: 開始画像ガむダンスは匷力ですが、セクション間で画像が倧きく異なるず、遷移が䞍自然になる可胜性がありたす。ガむダンスの匷さずスムヌズな流れの必芁性のバランスを取っおください。
  • プロンプトの最適化: 掚奚されるプロンプト内容はあくたでも参考です。モデルの芳察された挙動ず望たしい出力品質に基づいおプロンプトを埮調敎しおください。