Buckets:
Apache License, Version 2.0(「ライセンス」)の下でライセンスされています。
このファイルは、ライセンスに準拠した場合にのみ使用できます。
ライセンスのコピーは以下から入手できます
http://www.apache.org/licenses/LICENSE-2.0
適用される法律で要求される場合、または書面による合意がある場合を除き、ソフトウェア
ライセンスに基づき配布される本ソフトウェアは、「現状のまま」
明示的または黙示的を問わず、いかなる種類の保証や条件も付随しません。
権限を管理する特定の言語については、ライセンスを参照してください。
ライセンスの下での制限事項。
-->
CogVideoX
CogVideoX は、テキストからより長く、より一貫性のある動画を生成するために設計された、大規模な拡散トランスフォーマーモデルです。2B パラメータ版と 5B パラメータ版が提供されています。このモデルは、3D 因果的変分オートエンコーダーを使用することで、シーケンス長(およびそれに伴う学習計算量)を削減し、生成動画におけるちらつきを防止しながら、動画データをより効率的に処理します。適応型 LayerNorm を備えた「エキスパート」トランスフォーマーがテキストと動画の整合性を向上させ、3D フルアテンションが生成動画における動きや時間の正確なキャプチャを支援します。
すべてのオリジナルのCogVideoXチェックポイントは、CogVideoXコレクション内で確認できます。
他の動画生成タスクの例については、右側のサイドバーにあるCogVideoXモデルをクリックしてください。
以下の例では、メモリまたは推論速度に最適化されたビデオを生成する方法を示しています。
メモリ使用量の削減に関する詳細については、メモリ使用量の削減ガイドを参照してください。
以下の量子化された CogVideoX 5B モデルには、約16GBのVRAMが必要です。
import torch
from diffusers import CogVideoXPipeline, AutoModel, TorchAoConfig
from diffusers.quantizers import PipelineQuantizationConfig
from diffusers.hooks import apply_group_offloading
from diffusers.utils import export_to_video
from torchao.quantization import Int8WeightOnlyConfig
# quantize weights to int8 with torchao
pipeline_quant_config = PipelineQuantizationConfig(
quant_mapping={"transformer": TorchAoConfig(Int8WeightOnlyConfig())}
)
# fp8 layerwise weight-casting
transformer = AutoModel.from_pretrained(
"THUDM/CogVideoX-5b",
subfolder="transformer",
dtype=torch.bfloat16
)
transformer.enable_layerwise_casting(
storage_dtype=torch.float8_e4m3fn, compute_dtype=torch.bfloat16
)
pipeline = CogVideoXPipeline.from_pretrained(
"THUDM/CogVideoX-5b",
transformer=transformer,
quantization_config=pipeline_quant_config,
dtype=torch.bfloat16
)
pipeline.to("cuda") # or "mps", "xpu", "cpu"
# model-offloading
pipeline.enable_model_cpu_offload()
prompt = """
A detailed wooden toy ship with intricately carved masts and sails is seen gliding smoothly over a plush, blue carpet that mimics the waves of the sea.
The ship's hull is painted a rich brown, with tiny windows. The carpet, soft and textured, provides a perfect backdrop, resembling an oceanic expanse.
Surrounding the ship are various other toys and children's items, hinting at a playful environment. The scene captures the innocence and imagination of childhood,
with the toy ship's journey symbolizing endless adventures in a whimsical, indoor setting.
"""
video = pipeline(
prompt=prompt,
guidance_scale=6,
num_inference_steps=50
).frames[0]
export_to_video(video, "output.mp4", fps=8)
Compilationは初回に時間がかかりますが、その後のpipeline呼び出しは高速になります。
80GB A100 上で torch.compile を使用した場合の平均推論時間は 76.27 秒であり、コンパイルされていないモデルの 96.89 秒と比較できます。
import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video
pipeline = CogVideoXPipeline.from_pretrained(
"THUDM/CogVideoX-2b",
dtype=torch.float16
).to("cuda") # or "mps", "xpu", "cpu"
# torch.compile
pipeline.transformer.to(memory_format=torch.channels_last)
pipeline.transformer = torch.compile(
pipeline.transformer, mode="max-autotune", fullgraph=True
)
prompt = """
A detailed wooden toy ship with intricately carved masts and sails is seen gliding smoothly over a plush, blue carpet that mimics the waves of the sea.
The ship's hull is painted a rich brown, with tiny windows. The carpet, soft and textured, provides a perfect backdrop, resembling an oceanic expanse.
Surrounding the ship are various other toys and children's items, hinting at a playful environment. The scene captures the innocence and imagination of childhood,
with the toy ship's journey symbolizing endless adventures in a whimsical, indoor setting.
"""
video = pipeline(
prompt=prompt,
guidance_scale=6,
num_inference_steps=50
).frames[0]
export_to_video(video, "output.mp4", fps=8)
注記
CogVideoXは、load_lora_weights()によるLoRAをサポートしています。
サンプルコードを表示
import torch from diffusers import CogVideoXPipeline from diffusers.hooks import apply_group_offloading from diffusers.utils import export_to_video pipeline = CogVideoXPipeline.from_pretrained( "THUDM/CogVideoX-5b", dtype=torch.bfloat16 ) pipeline.to("cuda") # or "mps", "xpu", "cpu" # load LoRA weights pipeline.load_lora_weights("finetrainers/CogVideoX-1.5-crush-smol-v0", adapter_name="crush-lora") pipeline.set_adapters("crush-lora", 0.9) # model-offloading pipeline.enable_model_cpu_offload() prompt = """ PIKA_CRUSH A large metal cylinder is seen pressing down on a pile of Oreo cookies, flattening them as if they were under a hydraulic press. """ negative_prompt = "inconsistent motion, blurry motion, worse quality, degenerate outputs, deformed outputs" video = pipeline( prompt=prompt, negative_prompt=negative_prompt, num_frames=81, height=480, width=768, num_inference_steps=50 ).frames[0] export_to_video(video, "output.mp4", fps=16)テキストから動画への変換(T2V)チェックポイントは、事前学習が1360x768の解像度で行われたため、この解像度で最も良好に動作します。
画像から動画への変換(I2V)チェックポイントは、複数の解像度に対応しています。幅は768から1360まで変更可能ですが、高さは758に固定されています。また、高さおよび幅は16で割り切れる必要があります。
T2VとI2Vの両方のチェックポイントは、81フレームと161フレームで最も良好に動作します。生成された動画は16fpsで書き出すことをお勧めします。
各種メモリ節約技術が有効化された場合のメモリ使用量を確認するには、以下の表を参照してください。
メソッド メモリ使用量(有効) メモリ使用量(無効) enable_model_cpu_offload 19GB 33GB enable_sequential_cpu_offload <4GB 約33GB(推論速度が非常に遅い) enable_tiling 11GB(enable_model_cpu_offloadを使用) ---
CogVideoXPipeline[[diffusers.CogVideoXPipeline]]
diffusers.CogVideoXPipeline[[diffusers.CogVideoXPipeline]]
diffusers.CogVideoXPipeline(tokenizer: T5Tokenizer, text_encoder: T5EncoderModel, vae: AutoencoderKLCogVideoX, transformer: CogVideoXTransformer3DModel, scheduler: diffusers.schedulers.scheduling_ddim_cogvideox.CogVideoXDDIMScheduler | diffusers.schedulers.scheduling_dpm_cogvideox.CogVideoXDPMScheduler)
パラメータ:
vae (AutoencoderKL) : 動画を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
text_encoder (T5EncoderModel) : 凍結されたテキストエンコーダー。CogVideoX は T5 を使用しており、具体的には t5-v1_1-xxl バリアントです。
tokenizer (T5Tokenizer) : クラス T5Tokenizer の Tokenizer。
transformer (CogVideoXTransformer3DModel) : テキスト条件付きのCogVideoXTransformer3DModelで、エンコードされた動画の潜在変数(latents)のノイズ除去を行います。
scheduler (SchedulerMixin) : transformer と組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去に使用するスケジューラ。
CogVideoX を使用したテキストから動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。ライブラリがすべてのパイプラインに対して実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
call[[diffusers.CogVideoXPipeline.call]]
__call__(prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, height: int | None = None, width: int | None = None, num_frames: int | None = None, num_inference_steps: int = 50, timesteps: list[int] | None = None, guidance_scale: float = 6, use_dynamic_cfg: bool = False, num_videos_per_prompt: int = 1, eta: float = 0.0, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.FloatTensor] = None, prompt_embeds: typing.Optional[torch.FloatTensor] = None, negative_prompt_embeds: typing.Optional[torch.FloatTensor] = None, output_type: str = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 226)
パラメータ:
prompt (str または list[str]、省略可) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに prompt_embeds を渡す必要があります。
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
height (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像のピクセル単位の縦幅。最適な結果を得るため、デフォルトでは 480 に設定されています。
width (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像の幅(ピクセル単位)。最適な結果を得るため、デフォルトでは 720 に設定されています。
num_frames (int、デフォルトは48) : 生成するフレーム数。self.vae_scale_factor_temporalで割り切れる必要があります。CogVideoXは、num_secondsが6、fpsが8である(num_seconds * fps + 1)フレームで条件付けされるため、生成される動画には1フレーム余分に含まれます。ただし、動画は任意のfpsで保存できるため、満たす必要がある条件は上記の割り切れることのみです。
num_inference_steps (int、任意、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
timesteps (list[int]、任意) : set_timesteps メソッドで timesteps 引数をサポートするスケジューラーにおいて、デノイジングプロセスに使用するカスタムタイムステップ。num_inference_steps が渡された場合のデフォルトの動作が使用されます。降順で指定する必要があります。
guidance_scale (float、任意、デフォルト値は 7.0) : Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scale は、Imagen Paper の数式 2 の w として定義されています。guidance_scale > 1 を設定することでガイダンススケールが有効になります。ガイダンススケールを高くすると、prompt のテキストと密接に関連する画像の生成が促されますが、通常は画像の品質が低下する傾向があります。
use_dynamic_cfg (bool、任意、デフォルトはFalse) : True の場合、推論中にガイダンススケールを動的に調整します。
num_videos_per_prompt (int、optional、デフォルトは 1) : プロンプトごとに生成する動画の数を指定します。
eta (float、任意、デフォルト値は 0.0) : DDIM論文のパラメータ eta (η) に対応します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。
generator (torch.Generator または list[torch.Generator]、任意) : 生成を決定論的にするための torch ジェネレーター 1 つまたはそのリスト。
latents (torch.FloatTensor, 任意) : 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイズ付き潜在変数(latents)。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、潜在変数テンソルが生成されます。
prompt_embeds (torch.FloatTensor、任意) : 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.FloatTensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
output_type (str、任意、デフォルトは "pil") : 生成画像の出力形式。PIL(PIL.Image.Image)または np.array から選択します。
return_dict (bool、任意、デフォルトはTrue) : プレーンなタプルではなく~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutputを返すかどうか。
attention_kwargs (dict, 任意) : 指定された場合、diffusers.models.attention_processor の self.processor で定義されている AttentionProcessor に渡される kwargs の辞書です。
callback_on_step_end (Callable、任意) : 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。 callback_kwargs には、callback_on_step_end_tensor_inputs で指定されたすべてのテンソルのリストが含まれます。
callback_on_step_end_tensor_inputs (list, 任意) : callback_on_step_end 関数へのテンソル入力のリストです。リストで指定されたテンソルは、callback_kwargs 引数として渡されます。パイプラインクラスの ._callback_tensor_inputs 属性に列挙された変数のみを、リストに含めることができます。
max_sequence_length (int、デフォルトは 226) : エンコードされたプロンプトの最大シーケンス長です。self.transformer.config.max_text_seq_length と一致させる必要があります。一致しない場合、結果が劣化する可能性があります。
戻り値: CogVideoXPipelineOutput または tuple
return_dict が True の場合は CogVideoXPipelineOutput、それ以外の場合は tuple を返します。tuple を返す場合、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
>>> import torch
>>> from diffusers import CogVideoXPipeline
>>> from diffusers.utils import export_to_video
>>> # Models: "THUDM/CogVideoX-2b" or "THUDM/CogVideoX-5b"
>>> pipe = CogVideoXPipeline.from_pretrained("THUDM/CogVideoX-2b", torch_dtype=torch.float16).to("cuda")
>>> prompt = (
... "A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool in a serene bamboo forest. "
... "The panda's fluffy paws strum a miniature acoustic guitar, producing soft, melodic tunes. Nearby, a few other "
... "pandas gather, watching curiously and some clapping in rhythm. Sunlight filters through the tall bamboo, "
... "casting a gentle glow on the scene. The panda's face is expressive, showing concentration and joy as it plays. "
... "The background includes a small, flowing stream and vibrant green foliage, enhancing the peaceful and magical "
... "atmosphere of this unique musical performance."
... )
>>> video = pipe(prompt=prompt, guidance_scale=6, num_inference_steps=50).frames[0]
>>> export_to_video(video, "output.mp4", fps=8)
encode_prompt[[diffusers.CogVideoXPipeline.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, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 226, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
パラメータ:
prompt (str または list[str]、省略可能) : エンコードするプロンプト
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
do_classifier_free_guidance (bool、任意、デフォルトはTrue) : classifier free guidance を使用するかどうか。
num_videos_per_prompt (int、optional、デフォルトは 1) : 各プロンプトに対して生成すべき動画の数。結果の埋め込みを配置する torch デバイス
prompt_embeds (torch.Tensor, 任意) : 事前生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.Tensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
device : (torch.device, 任意): torch デバイス
dtype : (torch.dtype, 任意): torch dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
fuse_qkv_projections[[diffusers.CogVideoXPipeline.fuse_qkv_projections]]
fuse_qkv_projections()
融合されたQKV投影を有効にします。
unfuse_qkv_projections[[diffusers.CogVideoXPipeline.unfuse_qkv_projections]]
unfuse_qkv_projections()
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXImageToVideoPipeline[[diffusers.CogVideoXImageToVideoPipeline]]
diffusers.CogVideoXImageToVideoPipeline[[diffusers.CogVideoXImageToVideoPipeline]]
diffusers.CogVideoXImageToVideoPipeline(tokenizer: T5Tokenizer, text_encoder: T5EncoderModel, vae: AutoencoderKLCogVideoX, transformer: CogVideoXTransformer3DModel, scheduler: diffusers.schedulers.scheduling_ddim_cogvideox.CogVideoXDDIMScheduler | diffusers.schedulers.scheduling_dpm_cogvideox.CogVideoXDPMScheduler)
パラメータ:
vae (AutoencoderKL) : 動画を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
text_encoder (T5EncoderModel) : 凍結されたテキストエンコーダー。CogVideoX は T5 を使用しており、具体的には t5-v1_1-xxl バリアントです。
tokenizer (T5Tokenizer) : クラス T5Tokenizer の Tokenizer。
transformer (CogVideoXTransformer3DModel) : テキスト条件付きのCogVideoXTransformer3DModelで、エンコードされた動画の潜在変数(latents)のノイズ除去を行います。
scheduler (SchedulerMixin) : transformer と組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去に使用するスケジューラ。
CogVideoX を使用した画像から動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。ライブラリがすべてのパイプラインに対して実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
call[[diffusers.CogVideoXImageToVideoPipeline.call]]
__call__(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, height: int | None = None, width: int | None = None, num_frames: int = 49, num_inference_steps: int = 50, timesteps: list[int] | None = None, guidance_scale: float = 6, use_dynamic_cfg: bool = False, num_videos_per_prompt: int = 1, eta: float = 0.0, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.FloatTensor] = None, prompt_embeds: typing.Optional[torch.FloatTensor] = None, negative_prompt_embeds: typing.Optional[torch.FloatTensor] = None, output_type: str = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 226)
パラメータ:
image (PipelineImageInput) : 生成を条件づけるための入力画像。画像、画像のリスト、またはtorch.Tensorである必要があります。
prompt (str または list[str]、省略可) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに prompt_embeds を渡す必要があります。
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
height (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像のピクセル単位の縦幅。最適な結果を得るため、デフォルトでは 480 に設定されています。
width (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像の幅(ピクセル単位)。最適な結果を得るため、デフォルトでは 720 に設定されています。
num_frames (int、デフォルトは48) : 生成するフレーム数。self.vae_scale_factor_temporalで割り切れる必要があります。CogVideoXは、num_secondsが6、fpsが8である(num_seconds * fps + 1)フレームで条件付けされるため、生成される動画には1フレーム余分に含まれます。ただし、動画は任意のfpsで保存できるため、満たす必要がある条件は上記の割り切れることのみです。
num_inference_steps (int、任意、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
timesteps (list[int]、任意) : set_timesteps メソッドで timesteps 引数をサポートするスケジューラーにおいて、デノイジングプロセスに使用するカスタムタイムステップ。num_inference_steps が渡された場合のデフォルトの動作が使用されます。降順で指定する必要があります。
guidance_scale (float、任意、デフォルト値は 7.0) : Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scale は、Imagen Paper の数式 2 の w として定義されています。guidance_scale > 1 を設定することでガイダンススケールが有効になります。ガイダンススケールを高くすると、prompt のテキストと密接に関連する画像の生成が促されますが、通常は画像の品質が低下する傾向があります。
use_dynamic_cfg (bool、任意、デフォルトはFalse) : True の場合、推論中にガイダンススケールを動的に調整します。
num_videos_per_prompt (int、optional、デフォルトは 1) : プロンプトごとに生成する動画の数を指定します。
eta (float、任意、デフォルト値は 0.0) : DDIM論文のパラメータ eta (η) に対応します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。
generator (torch.Generator または list[torch.Generator]、任意) : 生成を決定論的にするための torch ジェネレーター 1 つまたはそのリスト。
latents (torch.FloatTensor, 任意) : 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイズ付き潜在変数(latents)。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、潜在変数テンソルが生成されます。
prompt_embeds (torch.FloatTensor、任意) : 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.FloatTensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
output_type (str、任意、デフォルトは "pil") : 生成画像の出力形式。PIL(PIL.Image.Image)または np.array から選択します。
return_dict (bool、任意、デフォルトはTrue) : プレーンなタプルではなく~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutputを返すかどうか。
attention_kwargs (dict, 任意) : 指定された場合、diffusers.models.attention_processor の self.processor で定義されている AttentionProcessor に渡される kwargs の辞書です。
callback_on_step_end (Callable、任意) : 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。 callback_kwargs には、callback_on_step_end_tensor_inputs で指定されたすべてのテンソルのリストが含まれます。
callback_on_step_end_tensor_inputs (list, 任意) : callback_on_step_end 関数へのテンソル入力のリストです。リストで指定されたテンソルは、callback_kwargs 引数として渡されます。パイプラインクラスの ._callback_tensor_inputs 属性に列挙された変数のみを、リストに含めることができます。
max_sequence_length (int、デフォルトは 226) : エンコードされたプロンプトの最大シーケンス長です。self.transformer.config.max_text_seq_length と一致させる必要があります。一致しない場合、結果が劣化する可能性があります。
戻り値: CogVideoXPipelineOutput または tuple
return_dict が True の場合は CogVideoXPipelineOutput、それ以外の場合は tuple を返します。tuple を返す場合、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
>>> import torch
>>> from diffusers import CogVideoXImageToVideoPipeline
>>> from diffusers.utils import export_to_video, load_image
>>> pipe = CogVideoXImageToVideoPipeline.from_pretrained("THUDM/CogVideoX-5b-I2V", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> prompt = "An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot."
>>> image = load_image(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
... )
>>> video = pipe(image, prompt, use_dynamic_cfg=True)
>>> export_to_video(video.frames[0], "output.mp4", fps=8)
encode_prompt[[diffusers.CogVideoXImageToVideoPipeline.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, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 226, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
パラメータ:
prompt (str または list[str]、省略可能) : エンコードするプロンプト
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
do_classifier_free_guidance (bool、任意、デフォルトはTrue) : classifier free guidance を使用するかどうか。
num_videos_per_prompt (int、optional、デフォルトは 1) : 各プロンプトに対して生成すべき動画の数。結果の埋め込みを配置する torch デバイス
prompt_embeds (torch.Tensor, 任意) : 事前生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.Tensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
device : (torch.device, 任意): torch デバイス
dtype : (torch.dtype, 任意): torch dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
fuse_qkv_projections[[diffusers.CogVideoXImageToVideoPipeline.fuse_qkv_projections]]
fuse_qkv_projections()
融合されたQKV投影を有効にします。
unfuse_qkv_projections[[diffusers.CogVideoXImageToVideoPipeline.unfuse_qkv_projections]]
unfuse_qkv_projections()
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXVideoToVideoPipeline[[diffusers.CogVideoXVideoToVideoPipeline]]
diffusers.CogVideoXVideoToVideoPipeline[[diffusers.CogVideoXVideoToVideoPipeline]]
diffusers.CogVideoXVideoToVideoPipeline(tokenizer: T5Tokenizer, text_encoder: T5EncoderModel, vae: AutoencoderKLCogVideoX, transformer: CogVideoXTransformer3DModel, scheduler: diffusers.schedulers.scheduling_ddim_cogvideox.CogVideoXDDIMScheduler | diffusers.schedulers.scheduling_dpm_cogvideox.CogVideoXDPMScheduler)
パラメータ:
vae (AutoencoderKL) : 動画を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
text_encoder (T5EncoderModel) : 凍結されたテキストエンコーダー。CogVideoX は T5 を使用しており、具体的には t5-v1_1-xxl バリアントです。
tokenizer (T5Tokenizer) : クラス T5Tokenizer の Tokenizer。
transformer (CogVideoXTransformer3DModel) : テキスト条件付きのCogVideoXTransformer3DModelで、エンコードされた動画の潜在変数(latents)のノイズ除去を行います。
scheduler (SchedulerMixin) : transformer と組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去に使用するスケジューラ。
CogVideoX を使用した動画から動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。ライブラリがすべてのパイプラインに対して実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
call[[diffusers.CogVideoXVideoToVideoPipeline.call]]
__call__(video: list[PIL.Image.Image] = None, prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 50, timesteps: list[int] | None = None, strength: float = 0.8, guidance_scale: float = 6, use_dynamic_cfg: bool = False, num_videos_per_prompt: int = 1, eta: float = 0.0, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.FloatTensor] = None, prompt_embeds: typing.Optional[torch.FloatTensor] = None, negative_prompt_embeds: typing.Optional[torch.FloatTensor] = None, output_type: str = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 226)
パラメータ:
video (list[PIL.Image.Image]) : 生成を条件づけるための入力動画。動画の画像/フレームのリストである必要があります。
prompt (str または list[str]、省略可) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに prompt_embeds を渡す必要があります。
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
height (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像のピクセル単位の縦幅。最適な結果を得るため、デフォルトでは 480 に設定されています。
width (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像の幅(ピクセル単位)。最適な結果を得るため、デフォルトでは 720 に設定されています。
num_inference_steps (int、任意、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
timesteps (list[int]、任意) : set_timesteps メソッドで timesteps 引数をサポートするスケジューラーにおいて、デノイジングプロセスに使用するカスタムタイムステップ。num_inference_steps が渡された場合のデフォルトの動作が使用されます。降順で指定する必要があります。
strength (float、任意、デフォルト値は 0.8) : 値が大きいほど、元の動画と生成された動画の差が大きくなります。
guidance_scale (float、任意、デフォルト値は 7.0) : Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scale は、Imagen Paper の数式 2 の w として定義されています。guidance_scale > 1 を設定することでガイダンススケールが有効になります。ガイダンススケールを高くすると、prompt のテキストと密接に関連する画像の生成が促されますが、通常は画像の品質が低下する傾向があります。
use_dynamic_cfg (bool、任意、デフォルトはFalse) : True の場合、推論中にガイダンススケールを動的に調整します。
num_videos_per_prompt (int、optional、デフォルトは 1) : プロンプトごとに生成する動画の数を指定します。
eta (float、任意、デフォルト値は 0.0) : DDIM論文のパラメータ eta (η) に対応します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。
generator (torch.Generator または list[torch.Generator]、任意) : 生成を決定論的にするための torch ジェネレーター 1 つまたはそのリスト。
latents (torch.FloatTensor, 任意) : 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイズ付き潜在変数(latents)。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、潜在変数テンソルが生成されます。
prompt_embeds (torch.FloatTensor、任意) : 事前に生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.FloatTensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを簡単に実行できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
output_type (str、任意、デフォルトは "pil") : 生成画像の出力形式。PIL(PIL.Image.Image)または np.array から選択します。
return_dict (bool、任意、デフォルトはTrue) : プレーンなタプルではなく~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutputを返すかどうか。
attention_kwargs (dict, 任意) : 指定された場合、diffusers.models.attention_processor の self.processor で定義されている AttentionProcessor に渡される kwargs の辞書です。
callback_on_step_end (Callable、任意) : 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。 callback_kwargs には、callback_on_step_end_tensor_inputs で指定されたすべてのテンソルのリストが含まれます。
callback_on_step_end_tensor_inputs (list, 任意) : callback_on_step_end 関数へのテンソル入力のリストです。リストで指定されたテンソルは、callback_kwargs 引数として渡されます。パイプラインクラスの ._callback_tensor_inputs 属性に列挙された変数のみを、リストに含めることができます。
max_sequence_length (int、デフォルトは 226) : エンコードされたプロンプトの最大シーケンス長です。self.transformer.config.max_text_seq_length と一致させる必要があります。一致しない場合、結果が劣化する可能性があります。
戻り値: CogVideoXPipelineOutput または tuple
return_dict が True の場合は CogVideoXPipelineOutput、それ以外の場合は tuple を返します。tuple を返す場合、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
>>> import torch
>>> from diffusers import CogVideoXDPMScheduler, CogVideoXVideoToVideoPipeline
>>> from diffusers.utils import export_to_video, load_video
>>> # Models: "THUDM/CogVideoX-2b" or "THUDM/CogVideoX-5b"
>>> pipe = CogVideoXVideoToVideoPipeline.from_pretrained("THUDM/CogVideoX-5b", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> pipe.scheduler = CogVideoXDPMScheduler.from_config(pipe.scheduler.config)
>>> input_video = load_video(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/hiker.mp4"
... )
>>> prompt = (
... "An astronaut stands triumphantly at the peak of a towering mountain. Panorama of rugged peaks and "
... "valleys. Very futuristic vibe and animated aesthetic. Highlights of purple and golden colors in "
... "the scene. The sky is looks like an animated/cartoonish dream of galaxies, nebulae, stars, planets, "
... "moons, but the remainder of the scene is mostly realistic."
... )
>>> video = pipe(
... video=input_video, prompt=prompt, strength=0.8, guidance_scale=6, num_inference_steps=50
... ).frames[0]
>>> export_to_video(video, "output.mp4", fps=8)
encode_prompt[[diffusers.CogVideoXVideoToVideoPipeline.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, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 226, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
パラメータ:
prompt (str または list[str]、省略可能) : エンコードするプロンプト
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
do_classifier_free_guidance (bool、任意、デフォルトはTrue) : classifier free guidance を使用するかどうか。
num_videos_per_prompt (int、optional、デフォルトは 1) : 各プロンプトに対して生成すべき動画の数。結果の埋め込みを配置する torch デバイス
prompt_embeds (torch.Tensor, 任意) : 事前生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.Tensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
device : (torch.device, 任意): torch デバイス
dtype : (torch.dtype, 任意): torch dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
fuse_qkv_projections[[diffusers.CogVideoXVideoToVideoPipeline.fuse_qkv_projections]]
fuse_qkv_projections()
融合されたQKV投影を有効にします。
unfuse_qkv_projections[[diffusers.CogVideoXVideoToVideoPipeline.unfuse_qkv_projections]]
unfuse_qkv_projections()
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXFunControlPipeline[[diffusers.CogVideoXFunControlPipeline]]
diffusers.CogVideoXFunControlPipeline[[diffusers.CogVideoXFunControlPipeline]]
diffusers.CogVideoXFunControlPipeline(tokenizer: T5Tokenizer, text_encoder: T5EncoderModel, vae: AutoencoderKLCogVideoX, transformer: CogVideoXTransformer3DModel, scheduler: KarrasDiffusionSchedulers)
パラメータ:
vae (AutoencoderKL) : 動画を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
text_encoder (T5EncoderModel) : 凍結されたテキストエンコーダー。CogVideoX は T5 を使用しており、具体的には t5-v1_1-xxl バリアントです。
tokenizer (T5Tokenizer) : クラス T5Tokenizer の Tokenizer。
transformer (CogVideoXTransformer3DModel) : テキスト条件付きのCogVideoXTransformer3DModelで、エンコードされた動画の潜在変数(latents)のノイズ除去を行います。
scheduler (SchedulerMixin) : transformer と組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去に使用するスケジューラ。
CogVideoX Fun を使用した制御可能なテキストから動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。ライブラリがすべてのパイプラインに対して実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
call[[diffusers.CogVideoXFunControlPipeline.call]]
__call__(prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, control_video: list[PIL.Image.Image] | None = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 50, timesteps: list[int] | None = None, guidance_scale: float = 6, use_dynamic_cfg: bool = False, num_videos_per_prompt: int = 1, eta: float = 0.0, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, control_video_latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 226)
パラメータ:
prompt (str または list[str]、省略可) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに prompt_embeds を渡す必要があります。
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
control_video (list[PIL.Image.Image]) : 生成を条件付けするためのコントロールビデオ。ビデオの画像/フレームのリストである必要があります。指定しない場合、control_video_latents を指定する必要があります。
height (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像のピクセル単位の縦幅。最適な結果を得るため、デフォルトでは 480 に設定されています。
width (int、optional、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) : 生成される画像の幅(ピクセル単位)。最適な結果を得るため、デフォルトでは 720 に設定されています。
num_inference_steps (int、任意、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
timesteps (list[int]、任意) : set_timesteps メソッドで timesteps 引数をサポートするスケジューラーにおいて、デノイジングプロセスに使用するカスタムタイムステップ。num_inference_steps が渡された場合のデフォルトの動作が使用されます。降順で指定する必要があります。
guidance_scale (float、任意、デフォルト値は 6.0) : Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scale は、Imagen Paper の数式 2 の w として定義されています。guidance_scale > 1 を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、prompt のテキストと密接に関連した画像の生成が促されますが、通常は画像の品質が低下する傾向があります。
use_dynamic_cfg (bool、任意、デフォルトはFalse) : True の場合、推論中にガイダンススケールを動的に調整します。
num_videos_per_prompt (int、optional、デフォルトは 1) : プロンプトごとに生成する動画の数を指定します。
eta (float、任意、デフォルト値は 0.0) : DDIM論文のパラメータ eta (η) に対応します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。
generator (torch.Generator または list[torch.Generator]、任意) : 生成を決定論的にするための torch ジェネレーター 1 つまたはそのリスト。
latents (torch.Tensor, 任意) : 動画生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイジー・ラテンツ。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、ラテンツのテンソルが生成されます。
control_video_latents (torch.Tensor, 任意) : 制御された動画生成の入力として使用される、ガウス分布からサンプリングされた事前生成された制御潜在変数です。指定されない場合、control_video を指定する必要があります。
prompt_embeds (torch.Tensor, 任意) : 事前生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.Tensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
output_type (str、任意、デフォルトは "pil") : 生成画像の出力形式。PIL(PIL.Image.Image)または np.array から選択します。
return_dict (bool、任意、デフォルトはTrue) : プレーンなタプルではなく~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutputを返すかどうか。
attention_kwargs (dict, 任意) : 指定された場合、diffusers.models.attention_processor の self.processor で定義されている AttentionProcessor に渡される kwargs の辞書です。
callback_on_step_end (Callable、任意) : 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。 callback_kwargs には、callback_on_step_end_tensor_inputs で指定されたすべてのテンソルのリストが含まれます。
callback_on_step_end_tensor_inputs (list, 任意) : callback_on_step_end 関数へのテンソル入力のリストです。リストで指定されたテンソルは、callback_kwargs 引数として渡されます。パイプラインクラスの ._callback_tensor_inputs 属性に列挙された変数のみを、リストに含めることができます。
max_sequence_length (int、デフォルトは 226) : エンコードされたプロンプトの最大シーケンス長です。self.transformer.config.max_text_seq_length と一致させる必要があります。一致しない場合、結果が劣化する可能性があります。
戻り値: CogVideoXPipelineOutput または tuple
return_dict が True の場合は CogVideoXPipelineOutput、それ以外の場合は tuple を返します。tuple を返す場合、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
>>> import torch
>>> from diffusers import CogVideoXFunControlPipeline, DDIMScheduler
>>> from diffusers.utils import export_to_video, load_video
>>> pipe = CogVideoXFunControlPipeline.from_pretrained(
... "alibaba-pai/CogVideoX-Fun-V1.1-5b-Pose", torch_dtype=torch.bfloat16
... )
>>> pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
>>> pipe.to("cuda")
>>> control_video = load_video(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/hiker.mp4"
... )
>>> prompt = (
... "An astronaut stands triumphantly at the peak of a towering mountain. Panorama of rugged peaks and "
... "valleys. Very futuristic vibe and animated aesthetic. Highlights of purple and golden colors in "
... "the scene. The sky is looks like an animated/cartoonish dream of galaxies, nebulae, stars, planets, "
... "moons, but the remainder of the scene is mostly realistic."
... )
>>> video = pipe(prompt=prompt, control_video=control_video).frames[0]
>>> export_to_video(video, "output.mp4", fps=8)
encode_prompt[[diffusers.CogVideoXFunControlPipeline.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, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 226, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
パラメータ:
prompt (str または list[str]、省略可能) : エンコードするプロンプト
negative_prompt (str または list[str]、省略可能) : 画像生成をガイドしないプロンプトです。定義されていない場合、代わりに negative_prompt_embeds を渡す必要があります。ガイドを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
do_classifier_free_guidance (bool、任意、デフォルトはTrue) : classifier free guidance を使用するかどうか。
num_videos_per_prompt (int、optional、デフォルトは 1) : 各プロンプトに対して生成すべき動画の数。結果の埋め込みを配置する torch デバイス
prompt_embeds (torch.Tensor, 任意) : 事前生成されたテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
negative_prompt_embeds (torch.Tensor, 任意) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、例えばプロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、negative_prompt 入力引数から negative_prompt_embeds が生成されます。
device : (torch.device, 任意): torch デバイス
dtype : (torch.dtype, 任意): torch dtype
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
fuse_qkv_projections[[diffusers.CogVideoXFunControlPipeline.fuse_qkv_projections]]
fuse_qkv_projections()
融合されたQKV投影を有効にします。
unfuse_qkv_projections[[diffusers.CogVideoXFunControlPipeline.unfuse_qkv_projections]]
unfuse_qkv_projections()
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXPipelineOutput[[diffusers.pipelines.cogvideo.pipeline_output.CogVideoXPipelineOutput]]
diffusers.pipelines.cogvideo.pipeline_output.CogVideoXPipelineOutput[[diffusers.pipelines.cogvideo.pipeline_output.CogVideoXPipelineOutput]]
diffusers.pipelines.cogvideo.pipeline_output.CogVideoXPipelineOutput(frames: Tensor)
パラメータ:
frames (torch.Tensor、np.ndarray、または list[list[PIL.Image.Image]]) : 動画出力のリスト - batch_size, 長のネストされたリストであり、各サブリストには num_frames. 長のデノイズ済み PIL 画像シーケンスが含まれる場合があります。また、(batch_size, num_frames, channels, height, width) の形状を持つ NumPy 配列や Torch テンソルである場合もあります。
CogVideo パイプライン用の出力クラスです。
Xet Storage Details
- Size:
- 68.5 kB
- Xet hash:
- 6e0932c8a578e4b55126277a0470d0ffea5d610aea7e2afe1caac6797b79828f
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.