Buckets:
Kandinsky 6
Kandinsky 6 は Kandinsky Lab による動画生成モデルのファミリーです。メインモデルは、単一のマルチモーダル拡散トランスフォーマーを用いて、テキストまたは参照画像から動画と同期した音声を生成します。動画と音声の潜在変数は、2つのモーダル間でクロスアテンションを行う融合ブロックを通じて一緒にノイズ除去され、それぞれが独自の Qwen2.5-VL テキストブランチと CLIP のプーリング埋め込みで条件付けられます。別の超解像モデルは、因果的な 3D K-VAE の潜在空間において、生成された動画をタイルごとにアップスケーリングします。
Hub上のKandinsky Lab組織では、ベースモデルとスーパーリゾリューションモデルの両方に関する、flow-matching版および蒸留版を含む公式チェックポイントの一式を確認できます。
蒸留済みチェックポイントは、少ステップのPiflowSchedulerに同梱されており、
guidance_scale=1.0で実行する必要があります。
利用可能なモデル
| モデル | パイプライン | 注記 |
|---|---|---|
kandinskylab/Kandinsky-6.0-Pro-5s-Diffusers |
Kandinsky6TI2VAPipeline | Flow matching、guidance_scale=5.0、50ステップ |
kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers |
Kandinsky6TI2VAPipeline | 蒸留済み、guidance_scale=1.0、10ステップ |
kandinskylab/Kandinsky-6.0-Lite-5s-Diffusers |
Kandinsky6TI2VAPipeline | Flow matching、guidance_scale=5.0、50ステップ |
kandinskylab/Kandinsky-6.0-Lite-distill-5s-Diffusers |
Kandinsky6TI2VAPipeline | 蒸留済み、guidance_scale=1.0、10ステップ |
kandinskylab/Kandinsky-6.0-Pro-pretrain-5s-Diffusers |
Kandinsky6TI2VAPipeline | Flow matching、guidance_scale=5.0、50ステップ |
kandinskylab/Kandinsky-6.0-Lite-pretrain-5s-Diffusers |
Kandinsky6TI2VAPipeline | Flow matching、guidance_scale=5.0、50ステップ |
kandinskylab/Kandinsky-6.0-VSR-5s-Diffusers |
Kandinsky6SRPipeline | Flow matchingによる超解像 |
kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers |
Kandinsky6SRPipeline | 蒸留されたスーパーレゾリューション、2ステップ |
テキスト/画像から動画と音声へ
import torch
from diffusers import Kandinsky6TI2VAPipeline
from diffusers.utils import encode_video
pipe = Kandinsky6TI2VAPipeline.from_pretrained(
"kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers", torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()
output = pipe(
prompt="A cat and a dog baking a cake together in a kitchen.",
height=480,
width=864,
num_frames=121,
num_inference_steps=10,
guidance_scale=1.0,
)
encode_video(
output.frames[0],
fps=24,
output_path="output.mp4",
audio=output.audio[0][None],
audio_sample_rate=pipe.audio_sample_rate,
)
image= を渡して最初のフレームを参照画像で条件付けし、sample_audio=False を渡して動画のみを生成し、expand_prompts=True を渡して Qwen2.5-VL テキストエンコーダーが短いプロンプトを詳細なプロンプトに書き換えるようにします。
ビデオ超解像
Kandinsky6SRPipeline は、Kandinsky6TI2VAPipeline が生成したフレームを 2、4、または 2.25(1.125 倍の双線形事前アップスケールに続けて 2 倍パス)に拡大します。動画は重複するタイルに分割され、各タイルは SR transformer が学習されたタイルサイズのいずれかで精細化され、その後 Hann ウィンドウを用いてタイルがブレンドされて再結合されます。
# required: lets inductor pick flex-attention tiles that fit the SR block mask
torch._inductor.config.max_autotune = True
sr_pipe = Kandinsky6SRPipeline.from_pretrained(
"kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers", torch_dtype=torch.bfloat16
)
# The SR transformer always runs NABLA sparse attention on the `flex` backend. Compile it, otherwise flex falls
# back to an eager implementation that needs far more memory at video resolutions.
sr_pipe.enable_model_cpu_offload()
sr_pipe.transformer.set_attention_backend("flex")
sr_pipe.transformer.compile_repeated_blocks(fullgraph=True)
upscaled = sr_pipe(video=output.frames[0], resolution_scale=2.25, num_inference_steps=2).frames[0]
メモリ最適化
一般的なテクニックについては、メモリ使用量の削減ガイドを参照してください。Kandinsky6TI2VAPipelineとKandinsky6SRPipelineの両方は、モデルオフローディング(上記で使用)をサポートしており、速度を犠牲にしてフットプリントを小さくする場合は、シーケンシャルCPUオフローディングも利用できます。
pipe.enable_sequential_cpu_offload()
Kandinsky6TI2VAPipelineの動画VAEは、高解像度や長時間の動画に対応するため、tiled decodingもサポートしています:
pipe.vae.enable_tiling()
注記
heightとwidthは、動画 VAE の空間圧縮率と transformer の patch size の積で割り切れる必要があります。デフォルトの Kandinsky6TI2VAPipeline 設定では16になります(圧縮率が8のAutoencoderKLHunyuanVideo、patch_size=(1, 2, 2))。上記の例で使用されている480x864は、この条件を満たしています。- Kandinsky6SRPipelineの入力
videoは、整数kに対して1 + k * vae_scale_factor_temporalフレームである必要があります(デフォルトのK-VAE設定では時間方向の圧縮比が4であるため、121フレームは有効ですが120フレームは不可です)。この条件を満たさない動画は、アップスケールする前にトリミングまたはパディングしてください。 expand_prompts=Trueは、デノイジングの前に追加の生成パスを実行するために、すでに読み込まれている Qwen2.5-VL のテキストエンコーダーを再利用します。そのため、レイテンシは増加しますが、追加のモデル重みは必要ありません。- 繰り返し推論を高速化するために、繰り返しされる Transformer ブロックをコンパイルします:
pipe.transformer.compile_repeated_blocks(fullgraph=True)
Kandinsky6TI2VAPipeline[[diffusers.Kandinsky6TI2VAPipeline]]
diffusers.Kandinsky6TI2VAPipeline[[diffusers.Kandinsky6TI2VAPipeline]]
diffusers.Kandinsky6TI2VAPipeline(transformer: Kandinsky6Transformer3DModel, vae: AutoencoderKLHunyuanVideo, text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: Qwen2_5_VLProcessor, text_encoder_2: CLIPTextModel, tokenizer_2: CLIPTokenizer, scheduler: diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_piflow.PiflowScheduler, audio_vae: diffusers.models.autoencoders.autoencoder_mmaudio.MMAudioVAE | None = None, vocoder: diffusers.models.autoencoders.mmaudio_vocoder.MMAudioVocoder | None = None)
パラメータ:
transformer (Kandinsky6Transformer3DModel) : 動画と音声の潜在変数をノイズ除去するマルチモーダル transformer です。
vae (AutoencoderKLHunyuanVideo) : 参照画像をエンコードし、生成された動画をデコードするために使用される Video VAE。
text_encoder (Qwen2_5_VLForConditionalGeneration) : Qwen2.5-VLモデルで、トークンレベルのテキスト埋め込みを提供し、オプションでプロンプト拡張を行います。
tokenizer (Qwen2_5_VLProcessor) : text_encoderのProcessorです。
text_encoder_2 (CLIPTextModel) : CLIPのテキストエンコーダーで、プールのテキスト埋め込みを提供します。
tokenizer_2 (CLIPTokenizer) : text_encoder_2のTokenizer。
scheduler (FlowMatchEulerDiscreteScheduler または PiflowScheduler) : transformer と組み合わせて、潜在変数のノイズ除去に使用されるスケジューラーです。蒸留済みチェックポイントには PiflowScheduler が同梱されており、guidance_scale=1.0 を指定して実行する必要があります。
audio_vae (MMAudioVAE、任意) : 生成されたオーディオの潜在変数をメロスペクトログラムにデコードするために使用されるオーディオ VAE。sample_audio=True の場合のみ必要です。
vocoder (MMAudioVocoder、任意) : audio_vae がデコードしたメルスペクトログラムを波形に変換するために使用される Vocoder。sample_audio=True の場合のみ必要です。
Kandinsky 6 によるテキスト/画像から動画と音声の生成を行う Pipeline です。
Videoとaudioのlatentsは、単一のマルチモーダルtransformerによって一緒にdenoiseされます。このtransformerは、Qwen2.5-VLのテキストトークンとCLIPのpooled embeddingを条件として使用します。任意の参照画像は、最初のフレームを条件付けます。
このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに実装されている汎用的なメソッド(ダウンロード、保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
call[[diffusers.Kandinsky6TI2VAPipeline.call]]
__call__(prompt: str | list[str] | None = None, image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, negative_prompt: str | list[str] | None = None, height: int = 512, width: int = 768, num_frames: int = 121, frame_rate: float = 24.0, num_inference_steps: int = 50, timesteps: list[int] | None = None, sigmas: list[float] | None = None, guidance_scale: float = 5.0, num_videos_per_prompt: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, audio_latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, sample_audio: bool = True, expand_prompts: bool = False, max_sequence_length: int = 1024, output_type: str = 'pil', return_dict: bool = True, callback_on_step_end: collections.abc.Callable[[int, int, dict], None] | None = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'])
パラメータ:
prompt (str または list[str]、任意) : 生成をガイドするためのプロンプトまたはプロンプトのリスト。prompt_embeds が指定されていない場合は必須です。
image (PipelineImageInput、任意) : 最初のフレームを条件付けする参照画像(image-to-video-and-audio)。
negative_prompt (str または list[str]、省略可能) : 生成をガイドしないプロンプトまたはプロンプトのリストです。デフォルトでは、Kandinsky 6 のネガティブプロンプトが使用されます。
height (int、デフォルトは512) : 生成される動画のピクセル単位の縦幅。
width (int、デフォルトは768) : 生成される動画の幅(ピクセル単位)。
num_frames (int、デフォルトは121) : 生成されるフレーム数。
frame_rate (float、デフォルトは24.0) : 動画が生成されるフレームレート。同期される音声の長さを設定します。
num_inference_steps (int、デフォルトは50) : デノイジングのステップ数です。蒸留済みチェックポイントを使用する場合は16を指定してください。
timesteps (list[int]、任意) : スケジューラがサポートするカスタムタイムステップ。
sigmas (list[float], 任意) : サポートしているスケジューラー用のカスタムシグマ。
guidance_scale (float、デフォルトは 5.0) : Classifier-free guidance のスケール。PiflowScheduler を使用する場合、1.0 である必要があります。
num_videos_per_prompt (int、デフォルトは1) : プロンプトごとに生成する動画の数を指定します。
generator (torch.Generator または list[torch.Generator]、任意) : 初期ノイズおよび参照画像のエンコーディングに使用されるジェネレーター。
latents (torch.Tensor, 任意) : 形状が (batch_size, channels, num_latent_frames, latent_height, latent_width) の、事前生成された動画の潜在変数。
audio_latents (torch.Tensor, 任意) : 形状が (batch_size, channels, audio_length) の事前生成されたオーディオ潜在変数。
prompt_embeds (torch.Tensor, 任意) : 事前生成済みの Qwen2.5-VL テキスト埋め込み。
pooled_prompt_embeds (torch.Tensor, 任意) : 事前に生成された CLIP のプーリング済みテキスト埋め込み。
negative_prompt_embeds (torch.Tensor, 任意) : 事前に生成された Qwen2.5-VL のテキスト埋め込みの負のサンプル。
negative_pooled_prompt_embeds (torch.Tensor, 任意) : 事前に生成された負の CLIP プール済みテキスト埋め込み。
sample_audio (bool、デフォルトはTrue) : 同期されたオーディオを生成するかどうか。audio_vaeとvocoderをパイプラインに含める必要があります。
expand_prompts (bool、デフォルトはFalse) : エンコードの前にexpand_prompts()でプロンプトを書き換えるかどうか。
max_sequence_length (int、デフォルトは1024) : チャットテンプレート適用後のプロンプトトークンの最大数。
output_type (str、デフォルトは "pil") : 生成される動画の出力形式: "pil"、"np"、"pt" または "latent"。
return_dict (bool、デフォルトはTrue) : プレーンなタプルではなく、Kandinsky6TI2VAPipelineOutputを返すかどうかを指定します。
callback_on_step_end (Callable、任意) : 各デノイジングステップの終了時に callback_on_step_end(self, step, timestep, callback_kwargs) で呼び出される関数です。リストされたテンソルを上書きする dict を返すことができます。
callback_on_step_end_tensor_inputs (list[str]、デフォルトは ["latents"]) : callback_on_step_end に渡されるテンソル入力。_callback_tensor_inputs の部分集合です。
戻り値: Kandinsky6TI2VAPipelineOutput または tuple
生成された動画と音声。return_dict=Falseの場合、(frames, audio)のタプル。
生成用の pipeline への呼び出し関数。
例:
>>> import torch
>>> from diffusers import Kandinsky6TI2VAPipeline
>>> from diffusers.utils import encode_video
>>> pipe = Kandinsky6TI2VAPipeline.from_pretrained(
... "kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers", torch_dtype=torch.bfloat16
... )
>>> pipe.enable_model_cpu_offload()
>>> output = pipe(
... prompt="A cat and a dog baking a cake together in a kitchen.",
... height=480,
... width=864,
... num_frames=121,
... num_inference_steps=16,
... guidance_scale=1.0,
... )
>>> encode_video(
... output.frames[0],
... fps=24,
... output_path="output.mp4",
... audio=output.audio[0][None],
... audio_sample_rate=pipe.audio_sample_rate,
... )
encode_image[[diffusers.Kandinsky6TI2VAPipeline.encode_image]]
encode_image(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], height: int, width: int, device: device, dtype: dtype, num_videos_per_prompt: int = 1, generator: typing.Optional[torch.Generator] = None)
参照画像を、VAEのscaling_factorでスケーリングされた、(batch_size, latent_height, latent_width, latent_channels)の形状を持つファーストフレームの潜変数(latents)にエンコードします。PIL画像はheight x widthにリサイズされ、中央クロップされます。テンソルおよび配列は、すでにそのサイズである必要があります。潜変数は、バッチ次元に沿ってnum_videos_per_prompt回繰り返されます。
encode_prompt[[diffusers.Kandinsky6TI2VAPipeline.encode_prompt]]
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_pooled_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 1024, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
パラメータ:
prompt (str または list[str]) : エンコードするプロンプト。
negative_prompt (str または list[str]、省略可能) : 生成をガイドしないプロンプト。do_classifier_free_guidance が False の場合は無視されます。
do_classifier_free_guidance (bool、デフォルトはTrue) : 否定プロンプトもエンコードするかどうか。
num_videos_per_prompt (int、デフォルトは1) : プロンプトごとに生成される動画の数。埋め込みはそれに従って繰り返し使用されます。
prompt_embeds (torch.Tensor、任意) : 事前生成済みの Qwen2.5-VL テキスト埋め込み。prompt のエンコードをスキップします。
pooled_prompt_embeds (torch.Tensor, 任意) : 事前に生成された CLIP のプーリング済みテキスト埋め込み。prompt_embeds と一緒に指定する必要があります。
prompt_attention_mask (torch.Tensor, 任意) : prompt_embedsのブール値パディングマスク。
negative_prompt_embeds (torch.Tensor, 任意) : 事前に生成された Qwen2.5-VL のテキスト埋め込みの負のサンプル。
negative_pooled_prompt_embeds (torch.Tensor, 任意) : 事前に生成された負の CLIP プール済みテキスト埋め込み。
negative_prompt_attention_mask (torch.Tensor, 任意) : negative_prompt_embedsのブール値パディングマスク。
max_sequence_length (int、デフォルトは1024) : チャットテンプレート適用後のプロンプトトークンの最大数。
device (torch.device, 任意) : テキストエンコーダーを実行するデバイス。
dtype (torch.dtype、任意) : 返される埋め込みの Dtype。
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
expand_prompts[[diffusers.Kandinsky6TI2VAPipeline.expand_prompts]]
expand_prompts(prompt: str | list[str], tokenizer, text_encoder, device: device, image: PIL.Image.Image | list[PIL.Image.Image] | None = None, max_sequence_length: int = 1024, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None)
パラメータ:
prompt (str または list[str]) : 展開するプロンプトまたはプロンプトのリスト。
tokenizer : Qwen2.5-VL のプロセッサ、例えば pipe.tokenizer。
text_encoder : Qwen2.5-VL モデル、例えば pipe.text_encoder など。
device (torch.device) : テキストエンコーダーを実行するデバイス。
image (PIL.Image.Image または list[PIL.Image.Image]、任意) : image-to-video 呼び出しの参照画像。
max_sequence_length (int、デフォルトは1024) : プロンプトごとに生成されるトークンの最大数。
generator (torch.Generator または list[torch.Generator]、任意) : サンプリングされた拡張のシードを設定します。リストの場合、prompt の長さと一致する必要があり、各アイテムごとに1つのジェネレーターを指定します。generate はグローバル RNG から抽選を行うため、このジェネレーターのシードからグローバル RNG がシードされます。その後の randn_tensor の呼び出しは、引き続き generator を直接使用します。
戻り値: str または list[str]
展開されたプロンプト。
Qwen2.5-VL テキストエンコーダーを使用して、短いプロンプトを詳細な動画+音声プロンプトに書き換えます。参照画像が指定されている場合は、それを根拠として使用します。パイプラインの実行前に単体で使用できるように、staticmethod として定義されています。
prepare_audio_latents[[diffusers.Kandinsky6TI2VAPipeline.prepare_audio_latents]]
prepare_audio_latents(batch_size: int, num_channels_latents: int, audio_length: int, dtype: dtype, device: device, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType], audio_latents: typing.Optional[torch.Tensor] = None)
Transformer の (batch_size, audio_length, channels) レイアウトでオーディオの潜在変数を返します。ユーザーが提供する audio_latents テンソルは、(batch_size, channels, audio_length) レイアウトであることが期待されます。
prepare_latents[[diffusers.Kandinsky6TI2VAPipeline.prepare_latents]]
prepare_latents(batch_size: int, num_channels_latents: int, height: int, width: int, num_frames: int, dtype: dtype, device: device, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType], latents: typing.Optional[torch.Tensor] = None)
transformer の (batch_size, num_frames, height, width, channels) レイアウトで、video latents を返します。ユーザーが提供する latents テンソルは、(batch_size, channels, num_frames, height, width) レイアウトであることが期待されます。
Kandinsky6SRPipeline[[diffusers.Kandinsky6SRPipeline]]
diffusers.Kandinsky6SRPipeline[[diffusers.Kandinsky6SRPipeline]]
diffusers.Kandinsky6SRPipeline(transformer: Kandinsky6SRTransformer3DModel, vae: Kandinsky6SRVAE, scheduler: diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_piflow.PiflowScheduler, latent_upscaler: diffusers.models.latent_upscaler.latent_upscaler_kandinsky6_sr.Kandinsky6SRLatentUpscalerBank | None = None)
パラメータ:
transformer (Kandinsky6SRTransformer3DModel) : 潜在タイルを精錬する Transformer です。
vae (Kandinsky6SRVAE) : 入力動画をエンコードし、精製されたタイルをデコードするために使用される因果的な動画K-VAE。
scheduler (FlowMatchEulerDiscreteScheduler または PiflowScheduler) : transformer と組み合わせてタイルのノイズ除去に使用するスケジューラーです。蒸留済みチェックポイントには PiflowScheduler が同梱されています。
latent_upscaler (Kandinsky6SRLatentUpscalerBank、任意) : 対応するスケール用の潜在アップスケーラー。
Kandinsky 6 による動画スーパーリゾリューションのパイプライン。
動画は重複する空間タイルに分割され、各タイルはモデルが学習されたタイルサイズ(transformer.config.tile_sizes)のいずれかを用いて SR transformer によって精錬され、精錬されたタイルは Hann ウィンドウを用いて再合成されます。パイプラインに latent_upscaler が存在する場合、タイルは動画全体の K-VAE 潜在変数から切り出され、潜在空間内でアップスケールされます。それ以外の場合は、ピクセルタイルが双線形補間によってアップスケールされ、エンコードされます。
このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに実装されている汎用的なメソッド(ダウンロード、保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
call[[diffusers.Kandinsky6SRPipeline.call]]
__call__(video: typing.Union[list[PIL.Image.Image], list[list[PIL.Image.Image]], numpy.ndarray, torch.Tensor], resolution_scale: float = 2.25, num_inference_steps: int = 4, timesteps: list[int] | None = None, sigmas: list[float] | None = None, lq_noise_scale: float = 0.7, min_overlap: float = 0.2, tiles_batch_size: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, output_type: str = 'pil', return_dict: bool = True)
パラメータ:
video (list[PIL.Image.Image]、np.ndarray または torch.Tensor) : preprocess_video() が受け入れる任意の形式の低解像度動画で、フレーム数は 1 + k * 4 です。サイズは VAE の空間係数の倍数に切り捨てられます。
resolution_scale (float、デフォルトは 2.25) : 空間方向の総アップスケール倍率: 2、4、または 2.25(1.125 倍の双線形事前アップスケールに 2 倍パスを適用)。
num_inference_steps (int、デフォルトは4) : タイルごとのデノイジングステップ数。蒸留済みチェックポイントを使用する場合は2を指定してください。
timesteps (list[int]、任意) : スケジューラがサポートするカスタムタイムステップ。
sigmas (list[float], 任意) : サポートしているスケジューラー用のカスタムシグマ。
lq_noise_scale (float、デフォルトは0.7) : 低解像度潜在変数に、デノイジング前に混合するガウスノイズの量(分散保存型)。
min_overlap (float、デフォルトは0.2) : タイルサイズに対する、隣接するタイル間の最小重複率。
tiles_batch_size (int、デフォルトは1) : 1回のtransformer呼び出しでデノイズされるタイルの数。
generator (torch.Generator または list[torch.Generator]、任意) : タイルに混合されるノイズに使用されるジェネレーターです。
output_type (str、デフォルトは "pil") : 生成される動画の出力形式: "pil"、"np" または "pt"。
return_dict (bool、デフォルトはTrue) : プレーンなタプルではなく、Kandinsky6SRPipelineOutputを返すかどうか。
戻り値: Kandinsky6SRPipelineOutput または tuple
超解像度化された動画。return_dict=False の場合、1要素のタプルです。
スーパーリゾリューション用の pipeline への呼び出し関数。
例:
>>> import torch
>>> from diffusers import Kandinsky6SRPipeline, Kandinsky6TI2VAPipeline
>>> from diffusers.utils import export_to_video
>>> pipe = Kandinsky6TI2VAPipeline.from_pretrained(
... "kandinskylab/Kandinsky-6.0-Pro-distill-5s-Diffusers", torch_dtype=torch.bfloat16
... )
>>> pipe.enable_model_cpu_offload()
>>> video = pipe(
... prompt="A cat and a dog baking a cake together in a kitchen.",
... height=480,
... width=864,
... num_inference_steps=16,
... guidance_scale=1.0,
... sample_audio=False,
... ).frames[0]
>>> sr_pipe = Kandinsky6SRPipeline.from_pretrained(
... "kandinskylab/Kandinsky-6.0-VSR-distilled2steps-5s-Diffusers", torch_dtype=torch.bfloat16
... )
>>> # The transformer always runs attention through the `flex` backend; compiling avoids the eager
>>> # fallback's much higher memory use at video resolutions.
>>> sr_pipe.transformer.compile_repeated_blocks(fullgraph=True)
>>> sr_pipe.enable_model_cpu_offload()
>>> output = sr_pipe(video=video, resolution_scale=2.25, num_inference_steps=2)
>>> export_to_video(output.frames[0], "output_sr.mp4", fps=24)
decode_latents[[diffusers.Kandinsky6SRPipeline.decode_latents]]
decode_latents(latents: Tensor)
スケーリングされた K-VAE 潜在変数を [-1, 1] の (batch_size, channels, num_frames, height, width) 形式の動画にデコードします。
encode_video[[diffusers.Kandinsky6SRPipeline.encode_video]]
encode_video(video: Tensor)
[-1, 1] 範囲の (batch_size, channels, num_frames, height, width) 形式の動画を、VAE の scaling_factor でスケーリングされた K-VAE 潜在変数にエンコードします。
Kandinsky6SRLatentUpscalerBank[[diffusers.Kandinsky6SRLatentUpscalerBank]]
diffusers.Kandinsky6SRLatentUpscalerBank[[diffusers.Kandinsky6SRLatentUpscalerBank]]
diffusers.Kandinsky6SRLatentUpscalerBank(in_channels: int = 64, stage_channels: tuple[int, int, int] = (2048, 1024, 512), num_pre_blocks: int = 5, num_mid_blocks: int = 3, num_post_blocks: int = 3, num_x2_adapter_blocks: int = 2, scales: tuple[int, ...] = (2, 4), scaling_factor: float = 0.910344004631042)
パラメータ:
in_channels (int、デフォルトは64) : 潜在チャネル数。
stage_channels (tuple[int, int, int]、デフォルトは (2048, 1024, 512)) : カスケードの3段階の各段階のフィーチャー幅。
num_pre_blocks (int、デフォルトは5) : x4モデルの最初のアップサンプリング前の残差ブロックの数。
num_mid_blocks (int、デフォルトは3) : 2つのアップサンプルの間の残差ブロックの数。
num_post_blocks (int、デフォルトは3) : 最後のアップサンプリングの後の残差ブロック。
num_x2_adapter_blocks (int、デフォルトは2) : x2モデルのアダプターの残差ブロック。
scales (tuple[int, ...]、デフォルトは(2, 4)) : バンクがアップスケーラーを提供する空間スケール。
scaling_factor (float、デフォルトは 0.910344) : 入力 latents が想定されるスケール(K-VAE の scaling_factor)を指定します。
Kandinsky6SRPipelineで使用される潜在アップスケーラーのバンク: 対応する空間スケールごとに1つのKandinsky6SRLatentUpscalerが、K-VAEの潜在変数に対して動作します。
forward[[diffusers.Kandinsky6SRLatentUpscalerBank.forward]]
forward(latents: Tensor, scale: int, return_dict: bool = True)
パラメータ:
latents (torch.Tensor、shape (batch_size, in_channels, num_frames, height, width)) : scaling_factor でスケーリングされた K-VAE の潜在変数。
scale (int) : 空間的なアップスケール係数。scales のいずれかです。
return_dict (bool、デフォルトはTrue) : プレーンなタプルではなく~models.autoencoder_kl.DecoderOutputを返すかどうか。
戻り値:
(batch_size, in_channels, num_frames, height * scale, width * scale) の形状を持つ、アップスケールされた潜在変数。
Kandinsky6TI2VAPipelineOutput[[diffusers.Kandinsky6TI2VAPipelineOutput]]
diffusers.Kandinsky6TI2VAPipelineOutput[[diffusers.Kandinsky6TI2VAPipelineOutput]]
diffusers.Kandinsky6TI2VAPipelineOutput(frames: typing.Union[torch.Tensor, numpy.ndarray, list[list[PIL.Image.Image]]], audio: typing.Union[torch.Tensor, numpy.ndarray, NoneType] = None)
パラメータ:
frames (torch.Tensor、np.ndarray、または list[list[PIL.Image.Image]]) : 生成された動画。batch_size の長さのネストされたリストで、各要素が num_frames 枚の PIL 画像を含むもの、または形状が (batch_size, num_frames, height, width, channels) / (batch_size, num_frames, channels, height, width) の NumPy 配列または torch テンソル。output_type="latent" の場合、形状が (batch_size, channels, num_latent_frames, latent_height, latent_width) の動画の潜在変数です。
audio (torch.Tensor または np.ndarray、任意) : 音声 VAE のサンプリングレートで、[-1, 1] の範囲にあり、形状が (batch_size, num_samples) の生成された波形。音声がサンプリングされなかった場合は None。output_type="latent" を指定した場合は、形状が (batch_size, channels, audio_length) の音声潜在変数。
Kandinsky6TI2VAPipeline の出力クラスです。
Kandinsky6SRPipelineOutput[[diffusers.Kandinsky6SRPipelineOutput]]
diffusers.Kandinsky6SRPipelineOutput[[diffusers.Kandinsky6SRPipelineOutput]]
diffusers.Kandinsky6SRPipelineOutput(frames: typing.Union[torch.Tensor, numpy.ndarray, list[list[PIL.Image.Image]]])
パラメータ:
frames (torch.Tensor、np.ndarray、または list[list[PIL.Image.Image]]) : 超解像処理が適用された動画。batch_size 長さのネストされたリストで、各要素が num_frames 枚の PIL 画像を含むもの、または形状が (batch_size, num_frames, height, width, channels) / (batch_size, num_frames, channels, height, width) の NumPy 配列または torch テンソルです。
Kandinsky6SRPipelineの出力クラスです。
Xet Storage Details
- Size:
- 40.5 kB
- Xet hash:
- b5eb511ae606e118c3c6c608fb5d8dd752f38d19aa2ccedf3540eab80017ea20
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.