Diffusers documentation

Helios

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

LoRA

Helios

北京大学およびByteDanceなどのShenghai Yuan、Yuanyang Yin、Zongjian Li、Xinwei Huang、Xiao Yang、Li YuanによるHelios: Real Real-Time Long Video Generation Model

  • 14Bの動画生成モデルであるHeliosを紹介する。Heliosは単一のNVIDIA H100 GPU上で17 FPSで動作し、分単位の生成をサポートしながら、強力なベースラインと同等の品質を実現する初のモデルである。 3つの重要な次元でブレークスルーを達成した。(1) self-forcing、error banks、keyframe samplingといった一般的な抗ドリフトのヒューリスティックを用いずに、長時間動画のドリフトに対する頑健性を確保すること。(2) KV-cache、causal masking、sparse attentionといった標準的な高速化技術を用いずにリアルタイム生成を実現すること。(3) パラレル化やシャーディングフレームワークを用いずに学習を行うことで、GPUメモリ80 GB以内に最大4つの14Bモデルを収容しながら、画像拡散モデル規模のバッチサイズを可能にすること。具体的には、HeliosはT2V、I2V、V2Vタスクをネイティブでサポートする統一入力表現を備えた14Bの自己回帰拡散モデルである。長時間動画生成におけるドリフトを軽減するため、その典型的な失敗モードを特徴付け、学習中にドリフトを明示的にシミュレートするシンプルかつ効果的な学習戦略を提案するとともに、根源的な原因から反復的な動きを排除する。効率化のため、履歴およびノイズ付きコンテキストを大幅に圧縮し、サンプリングステップ数を削減したことで、1.3Bの動画生成モデルと同等かそれ以下の計算コストを実現した。さらに、推論と学習の両方を高速化しつつメモリ消費量を削減するインフラストラクチャレベルの最適化を導入した。広範な実験により、Heliosは短時間動画および長時間動画の生成の両方で、従来の手法を一貫して上回ることが示された。すべてのコードとモデルは[この https URL](https://pku-yuangroup.github.io/Helios-Page)で入手できる。

Diffusersでは、以下のHeliosモデルがサポートされています:

  • Helios-Base: v-prediction、標準の CFG、カスタムの HeliosScheduler を採用した最高品質のモデル。
  • Helios-Mid: 中間ウェイト。v-prediction、CFG-Zero*、およびカスタムの HeliosScheduler を採用しています。
  • Helios-Distilled: x0-predictionとカスタムのHeliosDMDSchedulerにより、最高の効率を実現。

Helios モデルのより多くの動画生成の例については、右側のサイドバーをクリックしてください。

メモリと推論速度の最適化

以下の例では、メモリまたは推論速度に最適化されたテキストから動画の生成方法を示しています。

メモリ
推論速度

メモリ使用量の削減に関する詳細については、メモリ使用量の削減ガイドを参照してください。

以下のHeliosモデルには、約6GBのVRAMが必要です。

import torch
from diffusers import AutoModel, HeliosPipeline
from diffusers.hooks.group_offloading import apply_group_offloading
from diffusers.utils import export_to_video

vae = AutoModel.from_pretrained("BestWishYsh/Helios-Base", subfolder="vae", dtype=torch.float32)

# group-offloading
pipeline = HeliosPipeline.from_pretrained(
    "BestWishYsh/Helios-Base",
    vae=vae,
    dtype=torch.bfloat16
)
pipeline.enable_group_offload(
    onload_device=torch.device("cuda"),
    offload_device=torch.device("cpu"),
    offload_type="leaf_level",
    use_stream=True,
    record_stream=True,
)

prompt = """
A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue 
and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with 
a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, 
allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades 
of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and 
the vivid colors of its surroundings. A close-up shot with dynamic movement.
"""
negative_prompt = """
Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality,
low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured,
misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards
"""

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    num_frames=99,
    num_inference_steps=50,
    guidance_scale=5.0,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_base_t2v_output.mp4", fps=24)

Helios-Base による生成

以下の例では、Helios-Baseを使用して、テキスト、画像、またはビデオに基づいてビデオを生成する方法を示します。

使用方法
import torch
from diffusers import AutoModel, HeliosPipeline
from diffusers.utils import export_to_video, load_video, load_image

vae = AutoModel.from_pretrained("BestWishYsh/Helios-Base", subfolder="vae", dtype=torch.float32)

pipeline = HeliosPipeline.from_pretrained(
    "BestWishYsh/Helios-Base",
    vae=vae,
    dtype=torch.bfloat16
)
pipeline.to("cuda")  # or "mps", "xpu", "cpu"

negative_prompt = """
Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality,
low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured,
misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards
"""

# For Text-to-Video
prompt = """
A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue 
and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with 
a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, 
allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades 
of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and 
the vivid colors of its surroundings. A close-up shot with dynamic movement.
"""

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    num_frames=99,
    num_inference_steps=50,
    guidance_scale=5.0,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_base_t2v_output.mp4", fps=24)

# For Image-to-Video
prompt = """
A towering emerald wave surges forward, its crest curling with raw power and energy. Sunlight glints off the translucent water, 
illuminating the intricate textures and deep green hues within the wave’s body. A thick spray erupts from the breaking crest, 
casting a misty veil that dances above the churning surface. As the perspective widens, the immense scale of the wave becomes 
apparent, revealing the restless expanse of the ocean stretching beyond. The scene captures the ocean’s untamed beauty and 
relentless force, with every droplet and ripple shimmering in the light. The dynamic motion and vivid colors evoke both awe and 
respect for nature’s might.
"""
image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/wave.jpg"

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image=load_image(image_path).resize((640, 384)),
    num_frames=99,
    num_inference_steps=50,
    guidance_scale=5.0,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_base_i2v_output.mp4", fps=24)

# For Video-to-Video
prompt = """
A bright yellow Lamborghini Huracn Tecnica speeds along a curving mountain road, surrounded by lush green trees 
under a partly cloudy sky. The car's sleek design and vibrant color stand out against the natural backdrop, 
emphasizing its dynamic movement. The road curves gently, with a guardrail visible on one side, adding depth to 
the scene. The motion blur captures the sense of speed and energy, creating a thrilling and exhilarating atmosphere. 
A front-facing shot from a slightly elevated angle, highlighting the car's aggressive stance and the surrounding greenery.
"""
video_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/car.mp4"

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    video=load_video(video_path),
    num_frames=99,
    num_inference_steps=50,
    guidance_scale=5.0,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_base_v2v_output.mp4", fps=24)

Helios-Mid による生成

以下の例では、テキスト、画像、またはビデオに基づいてビデオを生成するためにHelios-Midを使用する方法を示しています。

使用方法
import torch
from diffusers import AutoModel, HeliosPyramidPipeline
from diffusers.utils import export_to_video, load_video, load_image

vae = AutoModel.from_pretrained("BestWishYsh/Helios-Mid", subfolder="vae", dtype=torch.float32)

pipeline = HeliosPyramidPipeline.from_pretrained(
    "BestWishYsh/Helios-Mid",
    vae=vae,
    dtype=torch.bfloat16
)
pipeline.to("cuda")  # or "mps", "xpu", "cpu"

negative_prompt = """
Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality,
low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured,
misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards
"""

# For Text-to-Video
prompt = """
A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue 
and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with 
a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, 
allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades 
of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and 
the vivid colors of its surroundings. A close-up shot with dynamic movement.
"""

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    num_frames=99,
    pyramid_num_inference_steps_list=[20, 20, 20],
    guidance_scale=5.0,
    use_zero_init=True,
    zero_steps=1,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_pyramid_t2v_output.mp4", fps=24)

# For Image-to-Video
prompt = """
A towering emerald wave surges forward, its crest curling with raw power and energy. Sunlight glints off the translucent water, 
illuminating the intricate textures and deep green hues within the wave’s body. A thick spray erupts from the breaking crest, 
casting a misty veil that dances above the churning surface. As the perspective widens, the immense scale of the wave becomes 
apparent, revealing the restless expanse of the ocean stretching beyond. The scene captures the ocean’s untamed beauty and 
relentless force, with every droplet and ripple shimmering in the light. The dynamic motion and vivid colors evoke both awe and 
respect for nature’s might.
"""
image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/wave.jpg"

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image=load_image(image_path).resize((640, 384)),
    num_frames=99,
    pyramid_num_inference_steps_list=[20, 20, 20],
    guidance_scale=5.0,
    use_zero_init=True,
    zero_steps=1,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_pyramid_i2v_output.mp4", fps=24)

# For Video-to-Video
prompt = """
A bright yellow Lamborghini Huracn Tecnica speeds along a curving mountain road, surrounded by lush green trees 
under a partly cloudy sky. The car's sleek design and vibrant color stand out against the natural backdrop, 
emphasizing its dynamic movement. The road curves gently, with a guardrail visible on one side, adding depth to 
the scene. The motion blur captures the sense of speed and energy, creating a thrilling and exhilarating atmosphere. 
A front-facing shot from a slightly elevated angle, highlighting the car's aggressive stance and the surrounding greenery.
"""
video_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/car.mp4"

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    video=load_video(video_path),
    num_frames=99,
    pyramid_num_inference_steps_list=[20, 20, 20],
    guidance_scale=5.0,
    use_zero_init=True,
    zero_steps=1,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_pyramid_v2v_output.mp4", fps=24)

Helios-Distilledによる生成

以下の例では、Helios-Distilledを使用して、テキスト、画像、またはビデオに基づいてビデオを生成する方法を示します。

使用方法
import torch
from diffusers import AutoModel, HeliosPyramidPipeline
from diffusers.utils import export_to_video, load_video, load_image

vae = AutoModel.from_pretrained("BestWishYsh/Helios-Distilled", subfolder="vae", dtype=torch.float32)

pipeline = HeliosPyramidPipeline.from_pretrained(
    "BestWishYsh/Helios-Distilled",
    vae=vae,
    dtype=torch.bfloat16
)
pipeline.to("cuda")  # or "mps", "xpu", "cpu"

negative_prompt = """
Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality,
low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured,
misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards
"""

# For Text-to-Video
prompt = """
A vibrant tropical fish swimming gracefully among colorful coral reefs in a clear, turquoise ocean. The fish has bright blue 
and yellow scales with a small, distinctive orange spot on its side, its fins moving fluidly. The coral reefs are alive with 
a variety of marine life, including small schools of colorful fish and sea turtles gliding by. The water is crystal clear, 
allowing for a view of the sandy ocean floor below. The reef itself is adorned with a mix of hard and soft corals in shades 
of red, orange, and green. The photo captures the fish from a slightly elevated angle, emphasizing its lively movements and 
the vivid colors of its surroundings. A close-up shot with dynamic movement.
"""

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    num_frames=240,
    pyramid_num_inference_steps_list=[2, 2, 2],
    guidance_scale=1.0,
    is_amplify_first_chunk=True,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_distilled_t2v_output.mp4", fps=24)

# For Image-to-Video
prompt = """
A towering emerald wave surges forward, its crest curling with raw power and energy. Sunlight glints off the translucent water, 
illuminating the intricate textures and deep green hues within the wave’s body. A thick spray erupts from the breaking crest, 
casting a misty veil that dances above the churning surface. As the perspective widens, the immense scale of the wave becomes 
apparent, revealing the restless expanse of the ocean stretching beyond. The scene captures the ocean’s untamed beauty and 
relentless force, with every droplet and ripple shimmering in the light. The dynamic motion and vivid colors evoke both awe and 
respect for nature’s might.
"""
image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/wave.jpg"

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image=load_image(image_path).resize((640, 384)),
    num_frames=240,
    pyramid_num_inference_steps_list=[2, 2, 2],
    guidance_scale=1.0,
    is_amplify_first_chunk=True,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_distilled_i2v_output.mp4", fps=24)

# For Video-to-Video
prompt = """
A bright yellow Lamborghini Huracn Tecnica speeds along a curving mountain road, surrounded by lush green trees 
under a partly cloudy sky. The car's sleek design and vibrant color stand out against the natural backdrop, 
emphasizing its dynamic movement. The road curves gently, with a guardrail visible on one side, adding depth to 
the scene. The motion blur captures the sense of speed and energy, creating a thrilling and exhilarating atmosphere. 
A front-facing shot from a slightly elevated angle, highlighting the car's aggressive stance and the surrounding greenery.
"""
video_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/car.mp4"

output = pipeline(
    prompt=prompt,
    negative_prompt=negative_prompt,
    video=load_video(video_path),
    num_frames=240,
    pyramid_num_inference_steps_list=[2, 2, 2],
    guidance_scale=1.0,
    is_amplify_first_chunk=True,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(output, "helios_distilled_v2v_output.mp4", fps=24)

テキストから動画への変換のデモ

プロンプト生成された動画
現代の都市バスを運転するバイキングの戦士。バスには乗客が満員です。バイキングは後ろに結んだ長い金髪と髭を生やし、毛皮で縁取られたヘルメットと鎧を身につけています。伝統的なチュニックとズボンを着用していますが、混雑した街路を運転する際にはシートベルトも着用しています。バスの内装は典型的なもので、日常の用事をこなす多様な乗客が座席に座っています。外側のショットでは、高層ビルや交通量を含む活気ある都市環境が映し出されています。ハンドルを握るバイキングに焦点を当てたミディアムショットで、決意に満ちた表情のクローズアップが時折挿入されます。
カメラトラックが左に移動しながら撮影したドキュメンタリー風の自然写真。カニが素早く穴に逃げ込む様子を捉えています。カニは硬く緑がかった茶色の甲羅と長いハサミを持ち、砂地を決意に満ちた速さで移動しています。砂に潜り込む際に体はわずかに弓なりに反り、小さな足跡を残しています。背景には、岩や貝殻が散らばった浅い浜辺が広がり、地平線には海岸線の穏やかな曲線が見えます。写真には自然でリアルな質感があり、カニの自然な動きと砂の質感を強調しています。やや上からのアングルでのクローズアップショットです。

Image-to-Videoのデモ

画像プロンプト生成された動画
曇天の下、田舎の道を疾走する鮮やかな赤のKia。周囲の畑や木々が遠くまで連なり、そのぼやけた動きが、モダンなデザインとダイナミックな動きを際立たせています。光沢のあるボディは曇天を映し出し、エアロダイナミックな形状とスポーティなスタンスを強調しています。ナンバープレートには「KIA 626」と表示され、ヘッドライトが点灯していることで、動きとエネルギーの感覚がさらに高まっています。道はゆるやかにカーブしており、車は少しオフセンターに配置されることで、前進する勢いが感じられます。力強い存在感を持つ車を、起伏のある丘と点在する木々という静かな背景に対して、ダイナミックなフロント3/4ビューで捉えています。
ふわふわのオレンジ色の猫のアップショットです。鮮やかな緑の瞳と白いひげが印象的で、カメラをじっと見つめています。毛並みは柔らかく手入れが行き届いており、温かみのあるオレンジ色とクリーム色が混ざり合っています。大きく表現力豊かな瞳は鮮やかな緑色で、好奇心と警戒心がうかがえます。鼻は小さくピンク色で、口はわずかに開き、ピンク色の舌が少し見えます。背景は柔らかくぼかされており、ニュートラルなトーンの落ち着いた室内であることを示唆しています。写真には浅い被写界深度が用いられており、猫の顔がくっきりと焦点を合わせている一方、背景はぼやけています。やや上からのアングルで撮影されたアップショットです。

インタラクティブ・ビデオのショーケース

プロンプト生成された動画
こちらでプロンプトを確認できます。
こちらでプロンプトを確認できます。

リソース

以下のリソースで、Heliosについて詳しく学んでください。

HeliosPipeline

class diffusers.HeliosPipeline

< >

( tokenizer: AutoTokenizertext_encoder: UMT5EncoderModelvae: AutoencoderKLWanscheduler: HeliosSchedulertransformer: HeliosTransformer3DModel )

パラメータ

  • tokenizer (T5Tokenizer) — T5 の Tokenizer、具体的には google/umt5-xxl バリアントです。
  • text_encoder (T5EncoderModel) — T5、具体的には google/umt5-xxl バリアントです。
  • transformer (HeliosTransformer3DModel) — 入力潜在変数をノイズ除去するための条件付き Transformer。
  • scheduler (HeliosScheduler) — transformer と組み合わせて、エンコードされた画像の潜在変数(latents)のノイズ除去を行うために使用するスケジューラ。
  • vae (AutoencoderKLWan) — 潜在表現へのエンコードとデコードを行う、動画用の変分オートエンコーダ (VAE) モデル。

Helios を使用したテキストから動画へ / 画像から動画へ / 動画から動画への生成を行う Pipeline です。

このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに実装されている汎用的なメソッド(ダウンロード、保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。

__call__

< >

( prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 384width: int = 640num_frames: int = 132num_inference_steps: int = 50sigmas: list = Noneguidance_scale: float = 5.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'np'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 = ['latents']max_sequence_length: int = 512image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = Noneimage_latents: typing.Optional[torch.Tensor] = Nonefake_image_latents: typing.Optional[torch.Tensor] = Noneadd_noise_to_image_latents: bool = Trueimage_noise_sigma_min: float = 0.111image_noise_sigma_max: float = 0.135video: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = Nonevideo_latents: typing.Optional[torch.Tensor] = Noneadd_noise_to_video_latents: bool = Truevideo_noise_sigma_min: float = 0.111video_noise_sigma_max: float = 0.135history_sizes: list = [16, 2, 1]num_latent_frames_per_chunk: int = 9keep_first_frame: bool = Trueis_skip_first_chunk: bool = False ) → ~HeliosPipelineOutput or tuple

パラメータ

  • prompt (str または list[str]、省略可) — 画像生成をガイドするためのプロンプトです。定義されていない場合は、代わりに prompt_embeds を渡してください。
  • negative_prompt (str または list[str]、任意) — 画像生成時に回避するプロンプトです。未定義の場合は、代わりにnegative_prompt_embedsを渡してください。guidance を使用していない場合(guidance_scale < 1)は無視されます。
  • height (int, デフォルトは 384) — 生成される画像の高さ(ピクセル単位)。
  • width (int、デフォルト値は640) — 生成される画像の幅(ピクセル単位)。
  • num_frames (int, デフォルトは 132) — 生成される動画のフレーム数です。
  • num_inference_steps (int、デフォルトは 50) — デノイジングのステップ数です。ステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
  • sigmas (list[float]、任意) — デノイジングプロセスに使用するカスタムシグマ。未定義の場合、スケジューラーのデフォルトスケジュールが使用されます。
  • guidance_scale (float、デフォルト値は 5.0) — Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。 guidance_scale は、Imagen Paper の数式 2 の w として定義されています。 guidance_scale > 1 を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、prompt のテキストと密接に関連した画像の生成が促されますが、通常は画像の品質が低下する傾向があります。
  • num_videos_per_prompt (int、省略可能、デフォルト値は 1)— プロンプトごとに生成する画像の数。
  • generator (torch.Generator または list[torch.Generator]、省略可) — 生成を決定論的にするための torch.Generator。
  • latents (torch.Tensor, 任意) — ガウス分布からサンプリングされた事前生成されたノイズ付き latents。画像生成のインプットとして使用します。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダム generator を用いてサンプリングを行い、latents テンソルが生成されます。
  • prompt_embeds (torch.Tensor, 任意) — 事前に生成されたテキスト埋め込みです。テキスト入力(プロンプトの重み付けなど)を簡単に調整するために使用できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
  • negative_prompt_embeds (torch.Tensor、任意) — 事前に生成されたネガティブなテキスト埋め込みです。指定されない場合、negative_prompt から生成されます。
  • output_type (str、任意、デフォルトは "np") — 生成された画像の出力形式。PIL.Image または np.array から選択します。
  • return_dict (bool、省略可能、デフォルトは True) — HeliosPipelineOutput を返すか、プレーンなタプルを返すかを指定します。
  • attention_kwargs (dict, 省略可) — 指定された場合、diffusers.models.attention_processor で定義されている self.processor 内の AttentionProcessor に渡される kwargs 辞書です。
  • callback_on_step_end (Callable、PipelineCallback、MultiPipelineCallbacks、省略可) — 推論中の各デノイジングステップの終了時に呼び出される関数、またはPipelineCallbackまたはMultiPipelineCallbacksのサブクラスです。引数は以下の通りです: 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、デフォルトは512) — テキストエンコーダーの最大シーケンス長です。プロンプトがこの長さを超える場合は切り詰められ、短い場合はこの長さにパディングされます。
  • image (PipelineImageInput、任意) — 画像から動画への条件付けに使用する入力画像。
  • image_latents (torch.Tensor、任意) — image の代わりに使用する、事前エンコード済みの画像潜在変数。
  • fake_image_latents (torch.Tensor, 任意) — 条件付けの過程で使用される、任意のフェイク画像潜在変数です。
  • add_noise_to_image_latents (bool、任意、デフォルトは True) — デノイジングの前に、画像の潜在変数にノイズを追加するかどうか。
  • image_noise_sigma_min (float、任意、デフォルトは 0.111) — 画像の潜在変数に追加されるノイズの最小 sigma 値。
  • image_noise_sigma_max (float、任意、デフォルトは 0.135) — 画像の潜在変数に追加されるノイズの最大 sigma 値。
  • video (PipelineImageInput、任意) — video-to-video の条件付けに使用する入力動画。
  • video_latents (torch.Tensor, 任意) — video の代わりに使用する、事前エンコード済みの動画潜在変数。
  • add_noise_to_video_latents (bool、任意、デフォルトは True) — デノイジングの前に、動画の潜在変数にノイズを追加するかどうか。
  • video_noise_sigma_min (float、任意、デフォルトは 0.111) — 動画の潜在変数に追加されるノイズの最小 sigma 値。
  • video_noise_sigma_max (float、任意、デフォルトは 0.135) — 動画の潜在変数に追加されるノイズの最大 sigma 値。
  • history_sizes (list、任意、デフォルトは [16, 2, 1]) — 自己回帰的なチャンク生成に使用される履歴ウィンドウサイズ。
  • num_latent_frames_per_chunk (int、任意、デフォルトは 9) — 自己回帰生成時に、各チャンクで生成される潜在フレームの数。
  • keep_first_frame (bool、省略可、デフォルトはTrue) — チャンク間で最初のフレームを保持するかどうかを指定します。
  • is_skip_first_chunk (bool、省略可、デフォルトは False) — 最初のチャンクの生成をスキップするかどうか。

戻り値

~HeliosPipelineOutput または tuple

return_dict が True の場合、HeliosPipelineOutput が返され、それ以外の場合は tuple が返されます。この tuple の最初の要素は生成された画像のリストであり、2番目の要素は、対応する生成画像に「not-safe-for-work」(nsfw)コンテンツが含まれているかどうかを示す bool のリストです。

生成用の pipeline への呼び出し関数。

例:

>>> import torch
>>> from diffusers.utils import export_to_video
>>> from diffusers import AutoencoderKLWan, HeliosPipeline

>>> # Available models: BestWishYsh/Helios-Base, BestWishYsh/Helios-Mid, BestWishYsh/Helios-Distilled
>>> model_id = "BestWishYsh/Helios-Base"
>>> vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
>>> pipe = HeliosPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
>>> negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"

>>> output = pipe(
...     prompt=prompt,
...     negative_prompt=negative_prompt,
...     height=384,
...     width=640,
...     num_frames=132,
...     guidance_scale=5.0,
... ).frames[0]
>>> export_to_video(output, "output.mp4", fps=24)

encode_prompt

< >

( 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

プロンプトをテキストエンコーダーの隠れ状態にエンコードします。

HeliosPyramidPipeline

class diffusers.HeliosPyramidPipeline

< >

( tokenizer: AutoTokenizertext_encoder: UMT5EncoderModelvae: AutoencoderKLWanscheduler: diffusers.schedulers.scheduling_helios.HeliosScheduler | diffusers.schedulers.scheduling_helios_dmd.HeliosDMDSchedulertransformer: HeliosTransformer3DModelis_cfg_zero_star: bool = Falseis_distilled: bool = False )

パラメータ

  • tokenizer (T5Tokenizer) — T5 の Tokenizer、具体的には google/umt5-xxl バリアントです。
  • text_encoder (T5EncoderModel) — T5、具体的には google/umt5-xxl バリアントです。
  • transformer (HeliosTransformer3DModel) — 入力潜在変数をノイズ除去するための条件付き Transformer。
  • scheduler ([HeliosScheduler, HeliosDMDScheduler]) — transformer と組み合わせて、エンコードされた画像の潜在変数からノイズを除去するために使用するスケジューラ。
  • vae (AutoencoderKLWan) — 潜在表現へのエンコードとデコードを行う、動画用の変分オートエンコーダ (VAE) モデル。

Helios を使用したテキストから動画へ / 画像から動画へ / 動画から動画への生成を行う Pipeline です。

このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに実装されている汎用的なメソッド(ダウンロード、保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。

__call__

< >

( prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 384width: int = 640num_frames: int = 132sigmas: list = Noneguidance_scale: float = 5.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'np'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 = ['latents']max_sequence_length: int = 512image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = Noneimage_latents: typing.Optional[torch.Tensor] = Nonefake_image_latents: typing.Optional[torch.Tensor] = Noneadd_noise_to_image_latents: bool = Trueimage_noise_sigma_min: float = 0.111image_noise_sigma_max: float = 0.135video: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = Nonevideo_latents: typing.Optional[torch.Tensor] = Noneadd_noise_to_video_latents: bool = Truevideo_noise_sigma_min: float = 0.111video_noise_sigma_max: float = 0.135history_sizes: list = [16, 2, 1]num_latent_frames_per_chunk: int = 9keep_first_frame: bool = Trueis_skip_first_chunk: bool = Falsepyramid_num_inference_steps_list: list = [10, 10, 10]use_zero_init: bool | None = Truezero_steps: int | None = 1is_amplify_first_chunk: bool = False ) → ~HeliosPipelineOutput or tuple

パラメータ

  • prompt (str または list[str]、省略可) — 画像生成をガイドするためのプロンプトです。定義されていない場合は、代わりに prompt_embeds を渡してください。
  • negative_prompt (str または list[str]、任意) — 画像生成時に回避するプロンプトです。未定義の場合は、代わりにnegative_prompt_embedsを渡してください。guidance を使用していない場合(guidance_scale < 1)は無視されます。
  • height (int, デフォルトは 384) — 生成される画像の高さ(ピクセル単位)。
  • width (int、デフォルト値は640) — 生成される画像の幅(ピクセル単位)。
  • num_frames (int, デフォルトは 132) — 生成される動画のフレーム数です。
  • sigmas (list[float]、任意) — デノイジングプロセスに使用するカスタムシグマ。未定義の場合、スケジューラーのデフォルトスケジュールが使用されます。
  • guidance_scale (float、デフォルト値は 5.0) — Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。 guidance_scale は、Imagen Paper の数式 2 の w として定義されています。 guidance_scale > 1 を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、prompt のテキストと密接に関連した画像の生成が促されますが、通常は画像の品質が低下する傾向があります。
  • num_videos_per_prompt (int、省略可能、デフォルト値は 1)— プロンプトごとに生成する画像の数。
  • generator (torch.Generator または list[torch.Generator]、省略可) — 生成を決定論的にするための torch.Generator。
  • latents (torch.Tensor, 任意) — ガウス分布からサンプリングされた事前生成されたノイズ付き latents。画像生成のインプットとして使用します。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダム generator を用いてサンプリングを行い、latents テンソルが生成されます。
  • prompt_embeds (torch.Tensor, 任意) — 事前に生成されたテキスト埋め込みです。テキスト入力(プロンプトの重み付けなど)を簡単に調整するために使用できます。指定されない場合、prompt 入力引数からテキスト埋め込みが生成されます。
  • negative_prompt_embeds (torch.Tensor、任意) — 事前に生成されたネガティブなテキスト埋め込みです。指定されない場合、negative_prompt から生成されます。
  • output_type (str、任意、デフォルトは "np") — 生成された画像の出力形式。PIL.Image または np.array から選択します。
  • return_dict (bool、省略可能、デフォルトは True) — HeliosPipelineOutput を返すか、プレーンなタプルを返すかを指定します。
  • attention_kwargs (dict, 省略可) — 指定された場合、diffusers.models.attention_processor で定義されている self.processor 内の AttentionProcessor に渡される kwargs 辞書です。
  • callback_on_step_end (Callable、PipelineCallback、MultiPipelineCallbacks、省略可) — 推論中の各デノイジングステップの終了時に呼び出される関数、またはPipelineCallbackまたはMultiPipelineCallbacksのサブクラスです。引数は以下の通りです: 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、デフォルトは512) — テキストエンコーダーの最大シーケンス長です。プロンプトがこの長さを超える場合は切り詰められ、短い場合はこの長さにパディングされます。
  • image (PipelineImageInput、任意) — 画像から動画への条件付けに使用する入力画像。
  • image_latents (torch.Tensor、任意) — image の代わりに使用する、事前エンコード済みの画像潜在変数。
  • fake_image_latents (torch.Tensor, 任意) — 条件付けの過程で使用される、任意のフェイク画像潜在変数です。
  • add_noise_to_image_latents (bool、任意、デフォルトは True) — デノイジングの前に、画像の潜在変数にノイズを追加するかどうか。
  • image_noise_sigma_min (float、任意、デフォルトは 0.111) — 画像の潜在変数に追加されるノイズの最小 sigma 値。
  • image_noise_sigma_max (float、任意、デフォルトは 0.135) — 画像の潜在変数に追加されるノイズの最大 sigma 値。
  • video (PipelineImageInput、任意) — video-to-video の条件付けに使用する入力動画。
  • video_latents (torch.Tensor, 任意) — video の代わりに使用する、事前エンコード済みの動画潜在変数。
  • add_noise_to_video_latents (bool、任意、デフォルトは True) — デノイジングの前に、動画の潜在変数にノイズを追加するかどうか。
  • video_noise_sigma_min (float、任意、デフォルトは 0.111) — 動画の潜在変数に追加されるノイズの最小 sigma 値。
  • video_noise_sigma_max (float、任意、デフォルトは 0.135) — 動画の潜在変数に追加されるノイズの最大 sigma 値。
  • history_sizes (list、任意、デフォルトは [16, 2, 1]) — 自己回帰的なチャンク生成に使用される履歴ウィンドウサイズ。
  • num_latent_frames_per_chunk (int、任意、デフォルトは 9) — 自己回帰生成時に、各チャンクで生成される潜在フレームの数。
  • keep_first_frame (bool、省略可、デフォルトはTrue) — チャンク間で最初のフレームを保持するかどうかを指定します。
  • is_skip_first_chunk (bool、省略可、デフォルトは False) — 最初のチャンクの生成をスキップするかどうか。
  • pyramid_num_inference_steps_list (list、任意、デフォルトは [10, 10, 10]) — Stage 2 生成時の、各ピラミッド段階における推論ステップ数です。
  • use_zero_init (bool、任意、デフォルトは True) — デノイジングの開始時に CFG zero-init を適用するかどうか。
  • zero_steps (int、任意、デフォルトは 1) — CFG zero-init を使用する初期ステップ数。
  • is_amplify_first_chunk (bool、任意、デフォルトは False) — 最初のチャンクでガイダンスを増幅するかどうか(DMD関連)。

戻り値

~HeliosPipelineOutput または tuple

return_dict が True の場合、HeliosPipelineOutput が返され、それ以外の場合は tuple が返されます。この tuple の最初の要素は生成された画像のリストであり、2番目の要素は、対応する生成画像に「not-safe-for-work」(nsfw)コンテンツが含まれているかどうかを示す bool のリストです。

生成用の pipeline への呼び出し関数。

例:

>>> import torch
>>> from diffusers.utils import export_to_video
>>> from diffusers import AutoencoderKLWan, HeliosPyramidPipeline

>>> # Available models: BestWishYsh/Helios-Base, BestWishYsh/Helios-Mid, BestWishYsh/Helios-Distilled
>>> model_id = "BestWishYsh/Helios-Base"
>>> vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
>>> pipe = HeliosPyramidPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
>>> negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"

>>> output = pipe(
...     prompt=prompt,
...     negative_prompt=negative_prompt,
...     height=384,
...     width=640,
...     num_frames=132,
...     guidance_scale=5.0,
... ).frames[0]
>>> export_to_video(output, "output.mp4", fps=24)

encode_prompt

< >

( 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

プロンプトをテキストエンコーダーの隠れ状態にエンコードします。

HeliosPipelineOutput

クラス diffusers.pipelines.helios.pipeline_output.HeliosPipelineOutput

< >

( frames: Tensor )

パラメータ

  • frames (torch.Tensor, np.ndarray, or List[List[PIL.Image.Image]]) — 動画出力のリストです。batch_size, 長のネストされたリストであり、各サブリストには num_frames. 長のノイズ除去済み PIL 画像シーケンスが含まれる場合があります。また、(batch_size, num_frames, channels, height, width) の形状を持つ NumPy 配列や Torch テンソルである場合もあります。

Helios パイプライン用の出力クラスです。

Update on GitHub