Diffusers documentation
Helios
Helios
Helios: Mô hình tạo video dài thời gian thực từ Đại học Bắc Kinh & ByteDance & v.v., bởi Shenghai Yuan, Yuanyang Yin, Zongjian Li, Xinwei Huang, Xiao Yang, Li Yuan.
- Chúng tôi giới thiệu Helios, mô hình tạo video 14B đầu tiên chạy ở tốc độ 17 FPS trên một GPU NVIDIA H100 duy nhất và hỗ trợ tạo video ở quy mô phút trong khi vẫn đạt chất lượng tương đương với một baseline mạnh. Chúng tôi đạt được những bước đột phá trên ba khía cạnh chính: (1) khả năng chống chịu với hiện tượng trôi dạt (drifting) trong video dài mà không cần sử dụng các heuristic chống trôi dạt phổ biến như self-forcing, error banks hay keyframe sampling; (2) tạo video thời gian thực mà không cần các kỹ thuật tăng tốc tiêu chuẩn như KV-cache, causal masking hay sparse attention; và (3) huấn luyện mà không cần các framework song song hoặc sharding, cho phép kích thước batch ở quy mô image-diffusion trong khi vẫn chứa được tới bốn mô hình 14B trong 80 GB bộ nhớ GPU. Cụ thể, Helios là một mô hình diffusion tự hồi quy (autoregressive) 14B với biểu diễn đầu vào thống nhất, hỗ trợ bản địa (natively) các tác vụ T2V, I2V và V2V. Để giảm thiểu trôi dạt trong tạo video dài, chúng tôi đặc trưng hóa các chế độ lỗi điển hình của nó và đề xuất các chiến lược huấn luyện đơn giản nhưng hiệu quả, trong đó mô phỏng rõ ràng hiện tượng trôi dạt trong quá trình huấn luyện, đồng thời loại bỏ chuyển động lặp đi lặp lại ngay từ nguồn gốc. Về hiệu quả, chúng tôi nén mạnh ngữ cảnh lịch sử và nhiễu, đồng thời giảm số bước sampling, dẫn đến chi phí tính toán tương đương hoặc thấp hơn so với các mô hình tạo video 1.3B. Hơn nữa, chúng tôi giới thiệu các tối ưu hóa ở cấp hạ tầng, giúp tăng tốc cả suy luận (inference) lẫn huấn luyện trong khi giảm mức tiêu thụ bộ nhớ. Các thí nghiệm mở rộng cho thấy Helios luôn vượt trội hơn các phương pháp trước đó trong cả tạo video ngắn lẫn video dài. Toàn bộ mã nguồn và mô hình có sẵn tại [this https URL](https://pku-yuangroup.github.io/Helios-Page).
Các mô hình Helios sau đây được hỗ trợ trong Diffusers:
- Helios-Base: Chất lượng tốt nhất, với v-prediction, CFG chuẩn và HeliosScheduler tùy chỉnh.
- Helios-Mid: Trọng lượng trung bình, với v-prediction, CFG-Zero* và HeliosScheduler tùy chỉnh.
- Helios-Distilled: Hiệu suất tốt nhất, với x0-prediction và HeliosDMDScheduler tùy chỉnh.
Nhấp vào các mô hình Helios ở thanh bên phải để xem thêm các ví dụ về tạo video.
Tối ưu hóa bộ nhớ và tốc độ suy luận
Ví dụ dưới đây minh họa cách tạo video từ văn bản được tối ưu hóa cho bộ nhớ hoặc tốc độ suy luận.
Tham khảo hướng dẫn Giảm mức sử dụng bộ nhớ để biết thêm chi tiết về các kỹ thuật tiết kiệm bộ nhớ khác nhau.
Mô hình Helios bên dưới yêu cầu ~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)Compilation sẽ chậm ở lần đầu tiên nhưng các lần gọi pipeline sau đó sẽ nhanh hơn. Attention Backends như FlashAttention và SageAttention có thể tăng tốc độ đáng kể bằng cách tối ưu hóa việc tính toán cơ chế attention. Context Parallelism chia nhỏ chuỗi đầu vào trên nhiều thiết bị để cho phép xử lý các ngữ cảnh dài song song, giảm áp lực bộ nhớ và độ trễ. Caching cũng có thể tăng tốc suy luận bằng cách lưu trữ và tái sử dụng các kết quả trung gian.
import torch
from diffusers import AutoModel, HeliosPipeline
from diffusers.utils import export_to_video
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"
# attention backend
# pipeline.transformer.set_attention_backend("flash")
pipeline.transformer.set_attention_backend("_flash_3_hub") # For Hopper GPUs
# torch.compile
torch.backends.cudnn.benchmark = True
pipeline.text_encoder.compile(mode="max-autotune-no-cudagraphs", dynamic=False)
pipeline.vae.compile(mode="max-autotune-no-cudagraphs", dynamic=False)
pipeline.transformer.compile(mode="max-autotune-no-cudagraphs", dynamic=False)
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)Tạo nội dung với Helios-Base
Ví dụ dưới đây minh họa cách sử dụng Helios-Base để tạo video dựa trên văn bản, hình ảnh hoặc video.
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)Tạo nội dung với Helios-Mid
Ví dụ dưới đây minh họa cách sử dụng Helios-Mid để tạo video dựa trên văn bản, hình ảnh hoặc video.
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)Tạo nội dung với Helios-Distilled
Ví dụ dưới đây minh họa cách sử dụng Helios-Distilled để tạo video dựa trên văn bản, hình ảnh hoặc video.
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)Các ví dụ về Text-to-Video
| Prompt | Video được tạo |
|---|---|
| Một chiến binh Viking lái xe buýt thành phố hiện đại chở đầy hành khách. Người Viking có mái tóc vàng dài buộc gọn, râu quai nón, đội mũ và mặc giáp có lót lông. Anh mặc áo choàng và quần truyền thống, nhưng cũng thắt dây an toàn khi tập trung điều khiển xe trên những con phố đông đúc. Nội thất bên trong xe buýt điển hình, với các hàng ghế được lấp đầy bởi những hành khách đa dạng đang thực hiện các hoạt động thường ngày. Các góc quay bên ngoài cho thấy môi trường đô thị nhộn nhịp, bao gồm các tòa nhà cao tầng và giao thông. Cảnh trung bình tập trung vào người Viking ở vô lăng, thỉnh thoảng có các cảnh cận mặt thể hiện vẻ quyết tâm của anh. | |
| Bức ảnh chụp thiên nhiên theo phong cách tài liệu, được ghi lại từ một chiếc xe tải camera đang di chuyển về phía bên trái, bắt trọn khoảnh khắc một con cua vội vã chui vào hang. Con cua có lớp vỏ cứng màu nâu xanh và đôi càng dài, di chuyển với tốc độ quyết đoán trên mặt đất cát. Thân nó hơi cong khi đào vào cát, để lại một vệt nhỏ phía sau. Nền ảnh cho thấy một bãi biển nông với những tảng đá và vỏ sò rải rác, đường chân trời hiện lên với đường cong nhẹ nhàng của bờ biển. Bức ảnh có kết cấu tự nhiên và chân thực, nhấn mạnh chuyển động tự nhiên của con cua và kết cấu của cát. Góc chụp cận cảnh từ một vị trí hơi cao hơn. |
Các ví dụ minh họa từ ảnh sang video
| Hình ảnh | Prompt | Video được tạo |
|---|---|---|
![]() | Một chiếc xe Kia màu đỏ bóng bẩy phóng nhanh trên con đường nông thôn dưới bầu trời nhiều mây, thiết kế hiện đại và chuyển động đầy năng động của xe được nhấn mạnh bởi cảnh quan mờ nhòe của những cánh đồng và hàng cây trải dài đến tận chân trời. Lớp sơn bóng của xe phản chiếu bầu trời u ám, làm nổi bật hình dáng khí động học và tư thế thể thao. Biển số xe ghi "KIA 626", và đèn pha của xe đang bật, góp phần tạo thêm cảm giác chuyển động và năng lượng. Con đường uốn lượn nhẹ nhàng, với chiếc xe được đặt hơi lệch khỏi tâm, tạo cảm giác về động lực tiến về phía trước. Góc nhìn ba phần tư phía trước đầy động lực ghi lại sự hiện diện mạnh mẽ của chiếc xe trên nền cảnh quan yên bình của những ngọn đồi nhấp nhô và những hàng cây rải rác. | |
![]() | Chụp cận cảnh một chú mèo cam xù lông với đôi mắt xanh lá cây nổi bật và ria mép trắng, nhìn chăm chú về phía máy ảnh. Lông của chú mèo mềm mại và được chăm sóc kỹ lưỡng, với sự pha trộn giữa các tông màu cam ấm và kem. Đôi mắt to, biểu cảm của chú có màu xanh lá cây rực rỡ, phản ánh sự tò mò và cảnh giác. Mũi của chú mèo nhỏ và hồng, miệng hơi hé mở, hé lộ một chút lưỡi hồng. Nền ảnh được làm mờ nhẹ, gợi lên một không gian trong nhà ấm cúng với các tông màu trung tính. Ảnh có độ sâu trường ảnh nông, tập trung sắc nét vào khuôn mặt của chú mèo trong khi nền vẫn bị mờ. Góc chụp cận cảnh từ một vị trí hơi cao hơn. |
Trưng bày Video Tương tác
| Prompt | Video được tạo |
|---|---|
| Câu hỏi gợi ý có thể được tìm thấy tại đây | |
| Câu hỏi gợi ý có thể được tìm thấy tại đây |
Tài nguyên
Tìm hiểu thêm về Helios với các tài nguyên sau.
- Xem video1 và video2 để xem cách sử dụng các tính năng chính của Helios.
- Xem thêm chi tiết trong bài nghiên cứu Helios: Real Real-Time Long Video Generation Model.
HeliosPipeline
lớp diffusers.HeliosPipeline
< source >( tokenizer: AutoTokenizertext_encoder: UMT5EncoderModelvae: AutoencoderKLWanscheduler: HeliosSchedulertransformer: HeliosTransformer3DModel )
Tham số
- tokenizer (
T5Tokenizer) — Tokenizer từ T5, cụ thể là biến thể google/umt5-xxl. - text_encoder (
T5EncoderModel) — T5, cụ thể là biến thể google/umt5-xxl. - transformer (HeliosTransformer3DModel) — Transformer có điều kiện để khử nhiễu các latents đầu vào.
- scheduler (HeliosScheduler) —
Một scheduler được sử dụng kết hợp với
transformerđể khử nhiễu các latents của ảnh đã mã hóa. - vae (AutoencoderKLWan) — Mô hình Variational Auto-Encoder (VAE) để mã hóa và giải mã video từ và sang các biểu diễn ẩn (latent representations).
Pipeline để tạo video từ văn bản / từ hình ảnh / từ video sử dụng Helios.
Mô hình này kế thừa từ DiffusionPipeline. Xem tài liệu của lớp cha để biết các phương thức chung được triển khai cho tất cả các pipeline (tải xuống, lưu, chạy trên một thiết bị cụ thể, v.v.).
__call__
< source >( 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
Tham số
- prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt để định hướng việc tạo ảnh. Nếu không được định nghĩa, hãy truyềnprompt_embedsthay thế. - negative_prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt cần tránh trong quá trình tạo ảnh. Nếu không được định nghĩa, hãy truyềnnegative_prompt_embedsthay thế. Tham số này bị bỏ qua khi không sử dụng guidance (guidance_scale<1). - height (
int, mặc định là384) — Chiều cao của hình ảnh được tạo ra, tính bằng pixel. - width (
int, mặc định là640) — Chiều rộng của hình ảnh được tạo ra, tính bằng pixel. - num_frames (
int, mặc định là132) — Số lượng khung hình trong video được tạo ra. - num_inference_steps (
int, mặc định là50) — Số bước khử nhiễu. Số bước khử nhiễu nhiều hơn thường dẫn đến hình ảnh có chất lượng cao hơn, với cái giá là suy luận chậm hơn. - sigmas (
list[float], tùy chọn) — Các sigma tùy chỉnh để sử dụng cho quá trình khử nhiễu. Nếu không được định nghĩa, lịch mặc định của trình lập lịch sẽ được sử dụng. - guidance_scale (
float, mặc định là5.0) — Thang độ dẫn hướng như được định nghĩa trong Classifier-Free Diffusion Guidance.guidance_scaleđược định nghĩa làwcủa phương trình 2. trong Imagen Paper. Thang độ dẫn hướng được kích hoạt bằng cách đặtguidance_scale > 1. Thang độ dẫn hướng cao hơn khuyến khích tạo ra các hình ảnh gắn kết chặt chẽ vớipromptvăn bản, thường phải đánh đổi bằng chất lượng hình ảnh thấp hơn. - num_videos_per_prompt (
int, tùy chọn, mặc định là 1) — Số lượng hình ảnh cần tạo cho mỗi prompt. - generator (
torch.Generatorhoặclist[torch.Generator], tùy chọn) — Mộttorch.Generatorđể làm cho quá trình sinh ra kết quả xác định. - latents (
torch.Tensor, tùy chọn) — Các latents nhiễu đã được tạo trước, lấy mẫu từ phân phối Gaussian, dùng làm đầu vào cho việc tạo ảnh. Có thể dùng để tinh chỉnh cùng một quá trình tạo với các prompt khác nhau. Nếu không được cung cấp, một tensor latents sẽ được tạo bằng cách lấy mẫu sử dụnggeneratorngẫu nhiên được cung cấp. - prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản (trọng số prompt). Nếu không được cung cấp, các embedding văn bản sẽ được tạo từ đối số đầu vàoprompt. - negative_prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản âm đã được tạo trước. Nếu không được cung cấp, chúng sẽ được tạo từnegative_prompt. - output_type (
str, tùy chọn, mặc định là"np") — Định dạng đầu ra của hình ảnh được tạo. Chọn giữaPIL.Imagehoặcnp.array. - return_dict (
bool, tùy chọn, mặc định làTrue) — Có nên trả về mộtHeliosPipelineOutputthay vì một tuple thông thường hay không. - attention_kwargs (
dict, tùy chọn) — Một từ điển kwargs, nếu được chỉ định, sẽ được truyền đếnAttentionProcessornhư đã định nghĩa dướiself.processortrong diffusers.models.attention_processor. - callback_on_step_end (
Callable,PipelineCallback,MultiPipelineCallbacks, tùy chọn) — Một hàm hoặc một lớp con củaPipelineCallbackhoặcMultiPipelineCallbacksđược gọi vào cuối mỗi bước khử nhiễu trong quá trình suy luận, với các đối số sau:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict).callback_kwargssẽ bao gồm một danh sách tất cả các tensor như được chỉ định bởicallback_on_step_end_tensor_inputs. - callback_on_step_end_tensor_inputs (
list, optional) — Danh sách các tensor đầu vào cho hàmcallback_on_step_end. Các tensor được chỉ định trong danh sách sẽ được truyền dưới dạng tham sốcallback_kwargs. Bạn chỉ có thể bao gồm các biến được liệt kê trong thuộc tính._callback_tensor_inputscủa lớp pipeline của bạn. - max_sequence_length (
int, mặc định là512) — Chiều dài tối đa của chuỗi cho bộ mã hóa văn bản. Nếu prompt dài hơn giá trị này, nó sẽ bị cắt bớt. Nếu prompt ngắn hơn, nó sẽ được đệm (padding) đến chiều dài này. - image (
PipelineImageInput, tùy chọn) — Ảnh đầu vào được sử dụng cho điều kiện từ ảnh sang video. - image_latents (
torch.Tensor, tùy chọn) — Các image latents đã được mã hóa trước để sử dụng thay choimage. - fake_image_latents (
torch.Tensor, tùy chọn) — Các latents ảnh giả tùy chọn được sử dụng trong quá trình điều kiện hóa. - add_noise_to_image_latents (
bool, tùy chọn, mặc định làTrue) — Có thêm nhiễu vào image latents trước khi khử nhiễu hay không. - image_noise_sigma_min (
float, tùy chọn, mặc định là0.111) — Giá trị sigma tối thiểu cho nhiễu được thêm vào các latent của ảnh. - image_noise_sigma_max (
float, tùy chọn, mặc định là0.135) — Giá trị sigma tối đa cho nhiễu được thêm vào latents của ảnh. - video (
PipelineImageInput, tùy chọn) — Video đầu vào được sử dụng cho điều kiện video-to-video. - video_latents (
torch.Tensor, tùy chọn) — Các video latents đã mã hóa trước để sử dụng thay chovideo. - add_noise_to_video_latents (
bool, tùy chọn, mặc định làTrue) — Có thêm nhiễu vào video latents trước khi khử nhiễu hay không. - video_noise_sigma_min (
float, tùy chọn, mặc định là0.111) — Giá trị sigma tối thiểu cho nhiễu được thêm vào các latent của video. - video_noise_sigma_max (
float, tùy chọn, mặc định là0.135) — Giá trị sigma tối đa cho nhiễu được thêm vào các latent của video. - history_sizes (
list, tùy chọn, mặc định là[16, 2, 1]) — Kích thước cửa sổ lịch sử được sử dụng cho việc tạo chunk tự hồi quy. - num_latent_frames_per_chunk (
int, tùy chọn, mặc định là9) — Số lượng khung tiềm năng (latent frames) được tạo ra cho mỗi khối (chunk) trong quá trình tạo tự hồi quy (autoregressive generation). - keep_first_frame (
bool, tùy chọn, mặc định làTrue) — Có nên giữ lại khung hình đầu tiên xuyên suốt các khối hay không. - is_skip_first_chunk (
bool, tùy chọn, mặc định làFalse) — Có bỏ qua việc tạo chunk đầu tiên hay không.
Trả về
~HeliosPipelineOutput hoặc tuple
Nếu return_dict là True, HeliosPipelineOutput sẽ được trả về, ngược lại một tuple sẽ được trả về trong đó
phần tử đầu tiên là một danh sách chứa các hình ảnh được tạo ra và phần tử thứ hai là một danh sách các bool
cho biết hình ảnh được tạo ra tương ứng có chứa nội dung “not-safe-for-work” (nsfw) hay không.
Hàm gọi call của pipeline để tạo nội dung.
Ví dụ:
>>> 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
< 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 )
Tham số
- prompt (
strhoặclist[str], tùy chọn) — prompt cần được mã hóa - negative_prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt không dùng để định hướng việc tạo ảnh. Nếu không được định nghĩa, cần truyềnnegative_prompt_embedsthay thế. Bỏ qua khi không sử dụng guidance (tức là bị bỏ qua nếuguidance_scalenhỏ hơn1). - do_classifier_free_guidance (
bool, tùy chọn, mặc định làTrue) — Có sử dụng classifier free guidance hay không. - num_videos_per_prompt (
int, tùy chọn, mặc định là 1) — Số lượng video cần được tạo cho mỗi prompt. torch device để đặt các embeddings kết quả - prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản, vd. trọng số prompt. Nếu không được cung cấp, các embedding văn bản sẽ được tạo từ đối số đầu vàoprompt. - negative_prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản âm đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản, vd. trọng số prompt. Nếu không được cung cấp, negative_prompt_embeds sẽ được tạo từ đối số đầu vàonegative_prompt. - device — (
torch.device, tùy chọn): thiết bị torch - dtype — (
torch.dtype, tùy chọn): torch dtype
Mã hóa prompt thành các trạng thái ẩn của text encoder.
HeliosPyramidPipeline
lớp diffusers.HeliosPyramidPipeline
< source >( 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 )
Tham số
- tokenizer (
T5Tokenizer) — Tokenizer từ T5, cụ thể là biến thể google/umt5-xxl. - text_encoder (
T5EncoderModel) — T5, cụ thể là biến thể google/umt5-xxl. - transformer (HeliosTransformer3DModel) — Transformer có điều kiện để khử nhiễu các latents đầu vào.
- scheduler ([
HeliosScheduler,HeliosDMDScheduler]) — Một scheduler được sử dụng kết hợp vớitransformerđể khử nhiễu các latents của ảnh đã mã hóa. - vae (AutoencoderKLWan) — Mô hình Variational Auto-Encoder (VAE) để mã hóa và giải mã video từ và sang các biểu diễn ẩn (latent representations).
Pipeline để tạo video từ văn bản / từ hình ảnh / từ video sử dụng Helios.
Mô hình này kế thừa từ DiffusionPipeline. Xem tài liệu của lớp cha để biết các phương thức chung được triển khai cho tất cả các pipeline (tải xuống, lưu, chạy trên một thiết bị cụ thể, v.v.).
__call__
< source >( 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
Tham số
- prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt để định hướng việc tạo ảnh. Nếu không được định nghĩa, hãy truyềnprompt_embedsthay thế. - negative_prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt cần tránh trong quá trình tạo ảnh. Nếu không được định nghĩa, hãy truyềnnegative_prompt_embedsthay thế. Tham số này bị bỏ qua khi không sử dụng guidance (guidance_scale<1). - height (
int, mặc định là384) — Chiều cao của hình ảnh được tạo ra, tính bằng pixel. - width (
int, mặc định là640) — Chiều rộng của hình ảnh được tạo ra, tính bằng pixel. - num_frames (
int, mặc định là132) — Số lượng khung hình trong video được tạo ra. - sigmas (
list[float], tùy chọn) — Các sigma tùy chỉnh để sử dụng cho quá trình khử nhiễu. Nếu không được định nghĩa, lịch mặc định của trình lập lịch sẽ được sử dụng. - guidance_scale (
float, mặc định là5.0) — Thang độ dẫn hướng như được định nghĩa trong Classifier-Free Diffusion Guidance.guidance_scaleđược định nghĩa làwcủa phương trình 2. trong Imagen Paper. Thang độ dẫn hướng được kích hoạt bằng cách đặtguidance_scale > 1. Thang độ dẫn hướng cao hơn khuyến khích tạo ra các hình ảnh gắn kết chặt chẽ vớipromptvăn bản, thường phải đánh đổi bằng chất lượng hình ảnh thấp hơn. - num_videos_per_prompt (
int, tùy chọn, mặc định là 1) — Số lượng hình ảnh cần tạo cho mỗi prompt. - generator (
torch.Generatorhoặclist[torch.Generator], tùy chọn) — Mộttorch.Generatorđể làm cho quá trình sinh ra kết quả xác định. - latents (
torch.Tensor, tùy chọn) — Các latents nhiễu đã được tạo trước, lấy mẫu từ phân phối Gaussian, dùng làm đầu vào cho việc tạo ảnh. Có thể dùng để tinh chỉnh cùng một quá trình tạo với các prompt khác nhau. Nếu không được cung cấp, một tensor latents sẽ được tạo bằng cách lấy mẫu sử dụnggeneratorngẫu nhiên được cung cấp. - prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản (trọng số prompt). Nếu không được cung cấp, các embedding văn bản sẽ được tạo từ đối số đầu vàoprompt. - negative_prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản âm đã được tạo trước. Nếu không được cung cấp, chúng sẽ được tạo từnegative_prompt. - output_type (
str, tùy chọn, mặc định là"np") — Định dạng đầu ra của hình ảnh được tạo. Chọn giữaPIL.Imagehoặcnp.array. - return_dict (
bool, tùy chọn, mặc định làTrue) — Có nên trả về mộtHeliosPipelineOutputthay vì một tuple thông thường hay không. - attention_kwargs (
dict, tùy chọn) — Một từ điển kwargs, nếu được chỉ định, sẽ được truyền đếnAttentionProcessornhư đã định nghĩa dướiself.processortrong diffusers.models.attention_processor. - callback_on_step_end (
Callable,PipelineCallback,MultiPipelineCallbacks, tùy chọn) — Một hàm hoặc một lớp con củaPipelineCallbackhoặcMultiPipelineCallbacksđược gọi vào cuối mỗi bước khử nhiễu trong quá trình suy luận, với các đối số sau:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict).callback_kwargssẽ bao gồm một danh sách tất cả các tensor như được chỉ định bởicallback_on_step_end_tensor_inputs. - callback_on_step_end_tensor_inputs (
list, optional) — Danh sách các tensor đầu vào cho hàmcallback_on_step_end. Các tensor được chỉ định trong danh sách sẽ được truyền dưới dạng tham sốcallback_kwargs. Bạn chỉ có thể bao gồm các biến được liệt kê trong thuộc tính._callback_tensor_inputscủa lớp pipeline của bạn. - max_sequence_length (
int, mặc định là512) — Chiều dài tối đa của chuỗi cho bộ mã hóa văn bản. Nếu prompt dài hơn giá trị này, nó sẽ bị cắt bớt. Nếu prompt ngắn hơn, nó sẽ được đệm (padding) đến chiều dài này. - image (
PipelineImageInput, tùy chọn) — Ảnh đầu vào được sử dụng cho điều kiện từ ảnh sang video. - image_latents (
torch.Tensor, tùy chọn) — Các image latents đã được mã hóa trước để sử dụng thay choimage. - fake_image_latents (
torch.Tensor, tùy chọn) — Các latents ảnh giả tùy chọn được sử dụng trong quá trình điều kiện hóa. - add_noise_to_image_latents (
bool, tùy chọn, mặc định làTrue) — Có thêm nhiễu vào image latents trước khi khử nhiễu hay không. - image_noise_sigma_min (
float, tùy chọn, mặc định là0.111) — Giá trị sigma tối thiểu cho nhiễu được thêm vào các latent của ảnh. - image_noise_sigma_max (
float, tùy chọn, mặc định là0.135) — Giá trị sigma tối đa cho nhiễu được thêm vào latents của ảnh. - video (
PipelineImageInput, tùy chọn) — Video đầu vào được sử dụng cho điều kiện video-to-video. - video_latents (
torch.Tensor, tùy chọn) — Các video latents đã mã hóa trước để sử dụng thay chovideo. - add_noise_to_video_latents (
bool, tùy chọn, mặc định làTrue) — Có thêm nhiễu vào video latents trước khi khử nhiễu hay không. - video_noise_sigma_min (
float, tùy chọn, mặc định là0.111) — Giá trị sigma tối thiểu cho nhiễu được thêm vào các latent của video. - video_noise_sigma_max (
float, tùy chọn, mặc định là0.135) — Giá trị sigma tối đa cho nhiễu được thêm vào các latent của video. - history_sizes (
list, tùy chọn, mặc định là[16, 2, 1]) — Kích thước cửa sổ lịch sử được sử dụng cho việc tạo chunk tự hồi quy. - num_latent_frames_per_chunk (
int, tùy chọn, mặc định là9) — Số lượng khung tiềm năng (latent frames) được tạo ra cho mỗi khối (chunk) trong quá trình tạo tự hồi quy (autoregressive generation). - keep_first_frame (
bool, tùy chọn, mặc định làTrue) — Có nên giữ lại khung hình đầu tiên xuyên suốt các khối hay không. - is_skip_first_chunk (
bool, tùy chọn, mặc định làFalse) — Có bỏ qua việc tạo chunk đầu tiên hay không. - pyramid_num_inference_steps_list (
list, tùy chọn, mặc định là[10, 10, 10]) — Số bước suy luận cho mỗi giai đoạn pyramid trong quá trình tạo Stage 2. - use_zero_init (
bool, tùy chọn, mặc định làTrue) — Có áp dụng CFG zero-init ở đầu quá trình denoising hay không. - zero_steps (
int, tùy chọn, mặc định là1) — Số bước ban đầu sử dụng CFG zero-init. - is_amplify_first_chunk (
bool, tùy chọn, mặc định làFalse) — Có khuếch đại hướng dẫn trên chunk đầu tiên (liên quan đến DMD) hay không.
Trả về
~HeliosPipelineOutput hoặc tuple
Nếu return_dict là True, HeliosPipelineOutput sẽ được trả về, ngược lại một tuple sẽ được trả về trong đó
phần tử đầu tiên là một danh sách chứa các hình ảnh được tạo ra và phần tử thứ hai là một danh sách các bool
cho biết hình ảnh được tạo ra tương ứng có chứa nội dung “not-safe-for-work” (nsfw) hay không.
Hàm gọi call của pipeline để tạo nội dung.
Ví dụ:
>>> 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
< 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 )
Tham số
- prompt (
strhoặclist[str], tùy chọn) — prompt cần được mã hóa - negative_prompt (
strhoặclist[str], tùy chọn) — Prompt hoặc các prompt không dùng để định hướng việc tạo ảnh. Nếu không được định nghĩa, cần truyềnnegative_prompt_embedsthay thế. Bỏ qua khi không sử dụng guidance (tức là bị bỏ qua nếuguidance_scalenhỏ hơn1). - do_classifier_free_guidance (
bool, tùy chọn, mặc định làTrue) — Có sử dụng classifier free guidance hay không. - num_videos_per_prompt (
int, tùy chọn, mặc định là 1) — Số lượng video cần được tạo cho mỗi prompt. torch device để đặt các embeddings kết quả - prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản, vd. trọng số prompt. Nếu không được cung cấp, các embedding văn bản sẽ được tạo từ đối số đầu vàoprompt. - negative_prompt_embeds (
torch.Tensor, tùy chọn) — Các embedding văn bản âm đã được tạo trước. Có thể dùng để dễ dàng điều chỉnh đầu vào văn bản, vd. trọng số prompt. Nếu không được cung cấp, negative_prompt_embeds sẽ được tạo từ đối số đầu vàonegative_prompt. - device — (
torch.device, tùy chọn): thiết bị torch - dtype — (
torch.dtype, tùy chọn): torch dtype
Mã hóa prompt thành các trạng thái ẩn của text encoder.
HeliosPipelineOutput
lớp diffusers.pipelines.helios.pipeline_output.HeliosPipelineOutput
< source >( frames: Tensor )
Tham số
- frames (
torch.Tensor,np.ndarray, hoặc List[List[PIL.Image.Image]]) — Danh sách các đầu ra video - Có thể là một danh sách lồng nhau có độ dàibatch_size,trong đó mỗi danh sách con chứa các chuỗi hình ảnh PIL đã khử nhiễu có độ dàinum_frames.Nó cũng có thể là một mảng NumPy hoặc tensor Torch có hình dạng(batch_size, num_frames, channels, height, width).
Lớp đầu ra cho các pipeline Helios.

