Diffusers documentation
CogVideoX
CogVideoX
CogVideoX は、テキストからより長く、より一貫性のある動画を生成するために設計された大規模な拡散トランスフォーマーモデルです。2B と 5B パラメータの 2 種類が提供されています。このモデルは、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
< source >( tokenizer: T5Tokenizertext_encoder: T5EncoderModelvae: AutoencoderKLCogVideoXtransformer: CogVideoXTransformer3DModelscheduler: diffusers.schedulers.scheduling_ddim_cogvideox.CogVideoXDDIMScheduler | diffusers.schedulers.scheduling_dpm_cogvideox.CogVideoXDPMScheduler )
パラメータ
- vae (AutoencoderKL) — 潜在表現へのエンコードとデコードを行う、Variational Auto-Encoder (VAE) モデル。
- text_encoder (
T5EncoderModel) — 凍結されたテキストエンコーダー。CogVideoX は T5を使用しており、具体的には t5-v1_1-xxlバリアントです。 - tokenizer (
T5Tokenizer) — クラス T5Tokenizer のトークナイザー。 - transformer (CogVideoXTransformer3DModel) —
テキスト条件付きの
CogVideoXTransformer3DModel。エンコードされた動画の潜在変数(latents)のノイズ除去に使用します。 - scheduler (SchedulerMixin) —
transformerと組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去を行うために使用するスケジューラ。
CogVideoX を使用したテキストから動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに対してライブラリが実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
__call__
< source >( prompt: str | list[str] | None = Nonenegative_prompt: str | list[str] | None = Noneheight: int | None = Nonewidth: int | None = Nonenum_frames: int | None = Nonenum_inference_steps: int = 50timesteps: list[int] | None = Noneguidance_scale: float = 6use_dynamic_cfg: bool = Falsenum_videos_per_prompt: int = 1eta: float = 0.0generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneprompt_embeds: typing.Optional[torch.FloatTensor] = Nonenegative_prompt_embeds: typing.Optional[torch.FloatTensor] = Noneoutput_type: str = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 226 ) → CogVideoXPipelineOutput or tuple
パラメータ
- prompt (
strまたはlist[str]、省略可) — 画像生成をガイドするためのプロンプトです。未定義の場合、代わりにprompt_embedsを渡す必要があります。 - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。ガイダンスを使用していない場合は無視されます(guidance_scaleが1未満の場合は無視されます)。 - height (
int, 任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の高さ(ピクセル単位)です。最適な結果を得るため、デフォルトでは 480 に設定されています。 - width (
int、任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 720 に設定されています。 - num_frames (
int, デフォルトは48) — 生成するフレーム数です。self.vae_scale_factor_temporal で割り切れる必要があります。CogVideoX は (num_seconds * fps + 1) フレームで条件付けされるため、生成される動画には 1 フレーム余分が含まれます。ここで num_seconds は 6、fps は 8 です。ただし、動画は任意の fps で保存できるため、満たす必要がある条件は上記の割り切れることのみです。 - num_inference_steps (
int、任意、デフォルト値は 50)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 - timesteps (
list[int], 任意) —timesteps引数をサポートするスケジューラーのset_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、任意、デフォルト値は 1) — 1 つのプロンプトごとに生成する動画の数です。 - eta (
float、任意、デフォルト値は 0.0) — DDIM論文のパラメータ eta (η) に対応します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。 - generator (
torch.Generatorまたはlist[torch.Generator]、省略可) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。 - latents (
torch.FloatTensor, 任意) — 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイジーな潜在変数です。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダム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
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: 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、任意、デフォルトは 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
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
融合されたQKV投影を有効にします。
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXImageToVideoPipeline
class diffusers.CogVideoXImageToVideoPipeline
< source >( tokenizer: T5Tokenizertext_encoder: T5EncoderModelvae: AutoencoderKLCogVideoXtransformer: CogVideoXTransformer3DModelscheduler: diffusers.schedulers.scheduling_ddim_cogvideox.CogVideoXDDIMScheduler | diffusers.schedulers.scheduling_dpm_cogvideox.CogVideoXDPMScheduler )
パラメータ
- vae (AutoencoderKL) — 潜在表現へのエンコードとデコードを行う、Variational Auto-Encoder (VAE) モデル。
- text_encoder (
T5EncoderModel) — 凍結されたテキストエンコーダー。CogVideoX は T5を使用しており、具体的には t5-v1_1-xxlバリアントです。 - tokenizer (
T5Tokenizer) — クラス T5Tokenizer のトークナイザー。 - transformer (CogVideoXTransformer3DModel) —
テキスト条件付きの
CogVideoXTransformer3DModel。エンコードされた動画の潜在変数(latents)のノイズ除去に使用します。 - scheduler (SchedulerMixin) —
transformerと組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去を行うために使用するスケジューラ。
CogVideoX を使用した画像から動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに対してライブラリが実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
__call__
< source >( 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 = Nonenegative_prompt: str | list[str] | None = Noneheight: int | None = Nonewidth: int | None = Nonenum_frames: int = 49num_inference_steps: int = 50timesteps: list[int] | None = Noneguidance_scale: float = 6use_dynamic_cfg: bool = Falsenum_videos_per_prompt: int = 1eta: float = 0.0generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneprompt_embeds: typing.Optional[torch.FloatTensor] = Nonenegative_prompt_embeds: typing.Optional[torch.FloatTensor] = Noneoutput_type: str = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 226 ) → CogVideoXPipelineOutput or tuple
パラメータ
- image (
PipelineImageInput) — 生成を条件づけるための入力画像です。画像、画像のリスト、またはtorch.Tensorである必要があります。 - prompt (
strまたはlist[str]、省略可) — 画像生成をガイドするためのプロンプトです。未定義の場合、代わりにprompt_embedsを渡す必要があります。 - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。ガイダンスを使用していない場合は無視されます(guidance_scaleが1未満の場合は無視されます)。 - height (
int, 任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の高さ(ピクセル単位)です。最適な結果を得るため、デフォルトでは 480 に設定されています。 - width (
int、任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 720 に設定されています。 - num_frames (
int, デフォルトは48) — 生成するフレーム数です。self.vae_scale_factor_temporal で割り切れる必要があります。CogVideoX は (num_seconds * fps + 1) フレームで条件付けされるため、生成される動画には 1 フレーム余分が含まれます。ここで num_seconds は 6、fps は 8 です。ただし、動画は任意の fps で保存できるため、満たす必要がある条件は上記の割り切れることのみです。 - num_inference_steps (
int、任意、デフォルト値は 50)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 - timesteps (
list[int], 任意) —timesteps引数をサポートするスケジューラーのset_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、任意、デフォルト値は 1) — 1 つのプロンプトごとに生成する動画の数です。 - eta (
float、任意、デフォルト値は 0.0) — DDIM論文のパラメータ eta (η) に対応します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。 - generator (
torch.Generatorまたはlist[torch.Generator]、省略可) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。 - latents (
torch.FloatTensor, 任意) — 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイジーな潜在変数です。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダム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
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: 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、任意、デフォルトは 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
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
融合されたQKV投影を有効にします。
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXVideoToVideoPipeline
class diffusers.CogVideoXVideoToVideoPipeline
< source >( tokenizer: T5Tokenizertext_encoder: T5EncoderModelvae: AutoencoderKLCogVideoXtransformer: CogVideoXTransformer3DModelscheduler: diffusers.schedulers.scheduling_ddim_cogvideox.CogVideoXDDIMScheduler | diffusers.schedulers.scheduling_dpm_cogvideox.CogVideoXDPMScheduler )
パラメータ
- vae (AutoencoderKL) — 潜在表現へのエンコードとデコードを行う、Variational Auto-Encoder (VAE) モデル。
- text_encoder (
T5EncoderModel) — 凍結されたテキストエンコーダー。CogVideoX は T5を使用しており、具体的には t5-v1_1-xxlバリアントです。 - tokenizer (
T5Tokenizer) — クラス T5Tokenizer のトークナイザー。 - transformer (CogVideoXTransformer3DModel) —
テキスト条件付きの
CogVideoXTransformer3DModel。エンコードされた動画の潜在変数(latents)のノイズ除去に使用します。 - scheduler (SchedulerMixin) —
transformerと組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去を行うために使用するスケジューラ。
CogVideoX を使用した動画から動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに対してライブラリが実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
__call__
< source >( video: list[PIL.Image.Image] = Noneprompt: str | list[str] | None = Nonenegative_prompt: str | list[str] | None = Noneheight: int | None = Nonewidth: int | None = Nonenum_inference_steps: int = 50timesteps: list[int] | None = Nonestrength: float = 0.8guidance_scale: float = 6use_dynamic_cfg: bool = Falsenum_videos_per_prompt: int = 1eta: float = 0.0generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneprompt_embeds: typing.Optional[torch.FloatTensor] = Nonenegative_prompt_embeds: typing.Optional[torch.FloatTensor] = Noneoutput_type: str = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 226 ) → CogVideoXPipelineOutput or tuple
パラメータ
- video (
list[PIL.Image.Image]) — 生成を条件づけるための入力動画です。動画の画像/フレームのリストである必要があります。 - prompt (
strまたはlist[str]、省略可) — 画像生成をガイドするためのプロンプトです。未定義の場合、代わりにprompt_embedsを渡す必要があります。 - negative_prompt (
strまたはlist[str]、省略可) — 画像生成をガイドしないプロンプトです。未定義の場合、代わりにnegative_prompt_embedsを渡す必要があります。ガイダンスを使用していない場合は無視されます(guidance_scaleが1未満の場合は無視されます)。 - height (
int, 任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の高さ(ピクセル単位)です。最適な結果を得るため、デフォルトでは 480 に設定されています。 - width (
int、任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 720 に設定されています。 - num_inference_steps (
int、任意、デフォルト値は 50)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 - timesteps (
list[int], 任意) —timesteps引数をサポートするスケジューラーのset_timestepsメソッドで、デノイジングプロセスに使用するカスタムタイムステップ。未定義の場合、num_inference_stepsが渡された際のデフォルトの動作が使用されます。降順で指定する必要があります。 - strength (
float、任意、デフォルト値は 0.8) — strength の値が高いほど、元の動画と生成された動画の差が大きくなります。 - 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、任意、デフォルト値は 1) — 1 つのプロンプトごとに生成する動画の数です。 - eta (
float、任意、デフォルト値は 0.0) — DDIM論文のパラメータ eta (η) に対応します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。 - generator (
torch.Generatorまたはlist[torch.Generator]、省略可) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。 - latents (
torch.FloatTensor, 任意) — 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイジーな潜在変数です。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダム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
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: 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、任意、デフォルトは 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
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
融合されたQKV投影を有効にします。
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXFunControlPipeline
class diffusers.CogVideoXFunControlPipeline
< source >( tokenizer: T5Tokenizertext_encoder: T5EncoderModelvae: AutoencoderKLCogVideoXtransformer: CogVideoXTransformer3DModelscheduler: KarrasDiffusionSchedulers )
パラメータ
- vae (AutoencoderKL) — 潜在表現へのエンコードとデコードを行う、Variational Auto-Encoder (VAE) モデル。
- text_encoder (
T5EncoderModel) — 凍結されたテキストエンコーダー。CogVideoX は T5を使用しており、具体的には t5-v1_1-xxlバリアントです。 - tokenizer (
T5Tokenizer) — クラス T5Tokenizer のトークナイザー。 - transformer (CogVideoXTransformer3DModel) —
テキスト条件付きの
CogVideoXTransformer3DModel。エンコードされた動画の潜在変数(latents)のノイズ除去に使用します。 - scheduler (SchedulerMixin) —
transformerと組み合わせて、エンコードされた動画の潜在変数(latents)のノイズ除去を行うために使用するスケジューラ。
CogVideoX Fun を使用した制御可能なテキストから動画への生成を行う Pipeline です。
このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに対してライブラリが実装している汎用的なメソッド(ダウンロードや保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
__call__
< source >( prompt: str | list[str] | None = Nonenegative_prompt: str | list[str] | None = Nonecontrol_video: list[PIL.Image.Image] | None = Noneheight: int | None = Nonewidth: int | None = Nonenum_inference_steps: int = 50timesteps: list[int] | None = Noneguidance_scale: float = 6use_dynamic_cfg: bool = Falsenum_videos_per_prompt: int = 1eta: float = 0.0generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Nonecontrol_video_latents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneoutput_type: str = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents']max_sequence_length: int = 226 ) → CogVideoXPipelineOutput or tuple
パラメータ
- 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, 任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の高さ(ピクセル単位)です。最適な結果を得るため、デフォルトでは 480 に設定されています。 - width (
int、任意、デフォルトは self.transformer.config.sample_height * self.vae_scale_factor_spatial) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 720 に設定されています。 - num_inference_steps (
int、任意、デフォルト値は 50)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 - timesteps (
list[int], 任意) —timesteps引数をサポートするスケジューラーのset_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、任意、デフォルト値は 1) — 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
< source >( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: 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、任意、デフォルトは 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
プロンプトをテキストエンコーダーの隠れ状態にエンコードします。
融合されたQKV投影を有効にします。
有効になっている場合、QKV 投影の融合を無効にします。
CogVideoXPipelineOutput
class diffusers.pipelines.cogvideo.pipeline_output.CogVideoXPipelineOutput
< source >( frames: Tensor )
CogVideo パイプライン用の出力クラスです。