Diffusers documentation
Helios
Helios
هيليوس: نموذج لتوليد مقاطع فيديو طويلة في الوقت الفعلي الحقيقي من جامعة بكين وByteDance وغيرهما، بقلم شينغهاي يوان، يوانيانغ يين، تسونغجيان لي، شينوي هوانغ، شياو يانغ، لي يوان.
- نقدّم Helios، وهو أول نموذج لتوليد الفيديو بحجم 14B يعمل بسرعة 17 إطارًا في الثانية على وحدة معالجة رسومات NVIDIA H100 واحدة، ويدعم التوليد على مقياس الدقائق مع الحفاظ على جودة تضاهي خط الأساس القوي. نحقق اختراقات في ثلاثة أبعاد رئيسية: (1) المتانة ضد انحراف الفيديو الطويل دون استخدام تقنيات تجريبية شائعة لمنع الانحراف مثل self-forcing أو error banks أو أخذ عينات من الإطارات الرئيسية؛ (2) التوليد في الوقت الفعلي دون استخدام تقنيات تسريع قياسية مثل KV-cache أو causal masking أو sparse attention؛ و(3) التدريب دون أطر التوازي أو تقسيم البيانات، مما يتيح أحجام دفع على مقياس انتشار الصور مع استيعاب ما يصل إلى أربعة نماذج بحجم 14B ضمن 80 جيجابايت من ذاكرة وحدة معالجة الرسومات. على وجه التحديد، Helios هو نموذج انتشار ذاتي التوليد بحجم 14B مع تمثيل موحّد للمدخلات يدعم بشكل أصلي مهام T2V وI2V وV2V. للتخفيف من الانحراف في توليد الفيديو الطويل، نحدد أنماط فشله النموذجية ونقترح استراتيجيات تدريب بسيطة وفعالة تحاكي الانحراف صراحةً أثناء التدريب، مع القضاء على الحركة التكرارية من مصدرها. من حيث الكفاءة، نضغط بشدة السياق التاريخي والضوضائي ونقلل عدد خطوات أخذ العينات، مما يؤدي إلى تكاليف حسابية مماثلة لتكاليف نماذج توليد الفيديو بحجم 1.3B أو أقل منها. علاوة على ذلك، نقدم تحسينات على مستوى البنية التحتية تسرّع كلًا من الاستدلال والتدريب مع تقليل استهلاك الذاكرة. تُظهر التجارب الواسعة أن Helios يتفوق باستمرار على الأساليب السابقة في كل من توليد الفيديو القصير والطويل. جميع الأكواد والنماذج متاحة في [هذا الرابط](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 أدناه حوالي 6 جيجابايت من ذاكرة 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)يكون التجميع بطيئًا في المرة الأولى، لكن الاستدعاءات اللاحقة للخط الأنابيب تكون أسرع. يمكن لخوادم الانتباه Attention Backends مثل FlashAttention وSageAttention أن تزيد السرعة بشكل كبير من خلال تحسين حساب آلية الانتباه. يقسم Context Parallelism تسلسل الإدخال عبر أجهزة متعددة لتمكين معالجة السياقات الطويلة بالتوازي، مما يقلل من ضغط الذاكرة وزمن الاستجابة. كما قد يسرّع Caching الاستدلال من خلال تخزين المخرجات الوسيطة وإعادة استخدامها.
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)التوليد باستخدام 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)عروض النماذج من النص إلى الفيديو
| الموجّه | الفيديو المولّد |
|---|---|
| محارب فيكنغ يقود حافلة مدينة حديثة مليئة بالركاب. المحارب شعره أشقر طويل مربوط للخلف، ولديه لحية، وهو يرتدي خوذة مدرّعة بالفراء ودروع. يرتدي تونيكًا وسروالًا تقليديين، لكنه يضع أيضًا حزام أمان بينما يركّز على التنقل في الشوارع المزدحمة. الداخلية للحافلة نموذجية، مع صفوف من المقاعد يشغلها ركاب متنوعون يمارسون روتينهم اليومي. اللقطات الخارجية تُظهر البيئة الحضرية النشطة، بما في ذلك المباني الشاهقة والمركبات. لقطة متوسطة تركز على المحارب خلف المقود، مع لقطات قريبة متقطعة تعكس تعبيره الحازم. | |
| لقطة تصوير طبيعية بأسلوب وثائقي من شاحنة كاميرا تتحرك إلى اليسار، تلتقط سرطانًا يزحف بسرعة إلى جحره. يمتلك السرطان قشرة صلبة بلون أخضر مائل إلى البني ومخالب طويلة، ويتحرك بسرعة حاسمة عبر الأرض الرملية. جسمه مقوس قليلاً بينما يحفر في الرمل، تاركًا أثرًا صغيرًا خلفه. يظهر في الخلفية شاطئ ضحل متناثرًا فيه الصخور والقواقع البحرية، بينما تتميز الأفق بمنحنى لطيف لخط الساحل. تتميز الصورة بملمس طبيعي وواقعي، مع التأكيد على الحركة الطبيعية للسرطان وملمس الرمل. لقطة مقرّبة من زاوية مرتفعة قليلاً. |
عروض من الصورة إلى الفيديو
| صورة | الموجّه | الفيديو المولّد |
|---|---|---|
![]() | سيارة كيا حمراء أنيقة تسير بسرعة على طريق ريفي تحت سماء غائمة، حيث يُبرز التصميم العصري والحركة الديناميكية ضبابية الحركة في الحقول والأشجار المحيطة الممتدة إلى الأفق. يعكس الطلاء اللامع لسطح السيارة السماء الملبدة بالغيوم، مما يُبرز شكلها الهوائي ومظهرها الرياضي. تحمل لوحة التسجيل الرقم "KIA 626"، ومصابيح السيارة الأمامية مضاءة، مما يزيد من إحساس الحركة والطاقة. ينحني الطريق بلطف، وتقع السيارة في موضع غير مركزي قليلاً، مما يخلق إحساساً بزخم أمامي. يلتقط منظور أمامي جانبي ثلاثي الأرباع وجود السيارة القوي مقابل خلفية هادئة من التلال المتدحرجة والأشجار المتناثرة. | |
![]() | تُظهر اللقطة القريبة قطًا برتقاليًا فخمًا بفراء كثيف، بعيون خضراء لافتة وشاربين أبيضين، يتأمل الكاميرا بتركيز. فراء القط ناعم ومعتنى به، يجمع بين درجات البرتقالي الدافئ والكريمي. عيناه الكبيرتان المعبرتان خضراوان زاهيتان، تعكسان الفضول واليقظة. أنفه صغير وردي، وفمه مفتوح قليلاً ليكشف عن لمحة من لسانه الوردي. الخلفية ضبابية ناعمة، مما يوحي ببيئة داخلية مريحة بدرجات محايدة. تتميز الصورة بعمق ميداني ضحل، حيث يتركز التركيز بوضوح على وجه القط بينما تبقى الخلفية غير واضحة. لقطة قريبة من منظور مرتفع قليلاً. |
عروض الفيديو التفاعلية
| الموجّه | الفيديو المولّد |
|---|---|
| يمكن العثور على الأمر في هذه الصفحة | |
| يمكن العثور على الأمر في هذه الصفحة |
الموارد
تعرف على المزيد حول Helios من خلال الموارد التالية.
- شاهد video1 و video2 للحصول على عرض توضيحي للميزات الرئيسية لـ Helios.
- الورقة البحثية، Helios: Real Real-Time Long Video Generation Model لمزيد من التفاصيل.
HeliosPipeline
فئة diffusers.HeliosPipeline
< source >( tokenizer: AutoTokenizertext_encoder: UMT5EncoderModelvae: AutoencoderKLWanscheduler: HeliosSchedulertransformer: HeliosTransformer3DModel )
المعاملات
- tokenizer (
T5Tokenizer) — مُقسِّم من T5، تحديداً النسخة google/umt5-xxl. - text_encoder (
T5EncoderModel) — T5، وتحديداً النسخة google/umt5-xxl. - transformer (HeliosTransformer3DModel) — نموذج Transformer مشروط لإزالة الضوضاء من المتغيرات الكامنة المدخلة.
- scheduler (HeliosScheduler) —
جدول زمني يُستخدم بالاقتران مع
transformerلإزالة الضوضاء من كائنات الصورة المُرمّزة. - vae (AutoencoderKLWan) — نموذج الترميز التبايني التلقائي (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
خط أنابيب لتوليد الفيديو من النص / من الصورة / من الفيديو باستخدام Helios.
يرث هذا النموذج من DiffusionPipeline. راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
__call__
< source >( prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 384width: int = 640num_frames: int = 132num_inference_steps: int = 50sigmas: list[float] = 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[str] = ['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_scale<1). - height (
int، القيمة الافتراضية384) — ارتفاع الصورة المولّدة بالبكسل. - width (
int، القيمة الافتراضية640) — عرض الصورة المولّدة بالبكسل. - num_frames (
int، القيمة الافتراضية132) — عدد الإطارات في الفيديو المولّد. - num_inference_steps (
int، القيمة الافتراضية50) — عدد خطوات إزالة الضوضاء. تؤدي زيادة عدد خطوات إزالة الضوضاء عادةً إلى صورة بجودة أعلى على حساب بطء الاستدلال. - sigmas (
list[float]، اختياري) — قيم sigmas مخصصة لاستخدامها في عملية إزالة الضوضاء. إذا لم تُعرَّف، يتم استخدام الجدول الافتراضي للمجدول. - guidance_scale (
float، القيمة الافتراضية5.0) — مقياس التوجيه كما هو معرّف في Classifier-Free Diffusion Guidance. يُعرَّفguidance_scaleعلى أنهwفي المعادلة 2 من Imagen Paper. يتم تفعيل مقياس التوجيه عن طريق تعيينguidance_scale > 1. كلما زاد مقياس التوجيه، شجّع ذلك على توليد صور مرتبطة ارتباطًا وثيقًا بـpromptالنصي، وعادةً على حساب انخفاض جودة الصورة. - num_videos_per_prompt (
int، اختياري، القيمة الافتراضية 1) — عدد الصور التي سيتم توليدها لكل موجه. - generator (
torch.Generatorأوlist[torch.Generator]، اختياري) —torch.Generatorلجعل التوليد حتميًا. - latents (
torch.Tensor، اختياري) — كائنات latents ضجيجية مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات لتوليد الصور. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كائن latents عن طريق الاستخراج باستخدامgeneratorالعشوائي المُقدَّم. - 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بدلاً من tuple عادي. - attention_kwargs (
dict، اختياري) — قاموس kwargs يُمرَّر إلىAttentionProcessorإذا تم تحديده، كما هو معرَّف تحتself.processorفي diffusers.models.attention_processor. - 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، اختياري) — قائمة مدخلات المصفوفات (tensors) لدالةcallback_on_step_end. سيتم تمرير المصفوفات المحددة في القائمة كحجةcallback_kwargs. لن تتمكن من تضمين متغيرات غير مدرجة في خاصية._callback_tensor_inputsلفئة خط الأنابيب (pipeline) الخاص بك. - 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) — أدنى قيمة لسيجما للضوضاء المضافة إلى كامنات الصورة. - image_noise_sigma_max (
float، اختياري، القيمة الافتراضية0.135) — القيمة القصوى لسيجما للضوضاء المضافة إلى كامنات الصورة. - video (
PipelineImageInput، اختياري) — الفيديو المُدخل المستخدم لتكييف الفيديو إلى فيديو. - video_latents (
torch.Tensor، اختياري) — كائنات فيديو مُرمّزة مسبقًا لاستخدامها بدلًا منvideo. - add_noise_to_video_latents (
bool، اختياري، القيمة الافتراضيةTrue) — ما إذا كان يجب إضافة ضوضاء إلى كامنات الفيديو قبل إزالة الضوضاء. - video_noise_sigma_min (
float، اختياري، القيمة الافتراضية0.111) — أدنى قيمة لسيجما للضوضاء المضافة إلى كامنات الفيديو. - video_noise_sigma_max (
float، اختياري، القيمة الافتراضية0.135) — القيمة القصوى لسيجما للضوضاء المضافة إلى كامنات الفيديو. - 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 حيث
العنصر الأول هو قائمة بالصور المولّدة والعنصر الثاني هو قائمة من قيم bool
تُشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى “غير آمن للعمل” (nsfw).
دالة الاستدعاء call لخط الأنابيب 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
< 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_embeds من معامل الإدخالnegative_prompt. - device — (
torch.device، اختياري): جهاز torch - dtype — (
torch.dtype، اختياري): نوع بيانات torch
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
HeliosPyramidPipeline
فئة 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 )
المعاملات
- tokenizer (
T5Tokenizer) — مُقسِّم من T5، تحديداً النسخة google/umt5-xxl. - text_encoder (
T5EncoderModel) — T5، وتحديداً النسخة google/umt5-xxl. - transformer (HeliosTransformer3DModel) — نموذج Transformer مشروط لإزالة الضوضاء من المتغيرات الكامنة المدخلة.
- scheduler ([
HeliosScheduler,HeliosDMDScheduler]) — جدولة تُستخدم بالاقتران معtransformerلإزالة الضوضاء من كامنات الصورة المُرمّزة. - vae (AutoencoderKLWan) — نموذج الترميز التبايني التلقائي (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
خط أنابيب لتوليد الفيديو من النص / من الصورة / من الفيديو باستخدام Helios.
يرث هذا النموذج من DiffusionPipeline. راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
__call__
< source >( prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 384width: int = 640num_frames: int = 132sigmas: list[float] = 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[str] = ['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_scale<1). - height (
int، القيمة الافتراضية384) — ارتفاع الصورة المولّدة بالبكسل. - width (
int، القيمة الافتراضية640) — عرض الصورة المولّدة بالبكسل. - num_frames (
int، القيمة الافتراضية132) — عدد الإطارات في الفيديو المولّد. - sigmas (
list[float]، اختياري) — قيم sigmas مخصصة لاستخدامها في عملية إزالة الضوضاء. إذا لم تُعرَّف، يتم استخدام الجدول الافتراضي للمجدول. - guidance_scale (
float، القيمة الافتراضية5.0) — مقياس التوجيه كما هو معرّف في Classifier-Free Diffusion Guidance. يُعرَّفguidance_scaleعلى أنهwفي المعادلة 2 من Imagen Paper. يتم تفعيل مقياس التوجيه عن طريق تعيينguidance_scale > 1. كلما زاد مقياس التوجيه، شجّع ذلك على توليد صور مرتبطة ارتباطًا وثيقًا بـpromptالنصي، وعادةً على حساب انخفاض جودة الصورة. - num_videos_per_prompt (
int، اختياري، القيمة الافتراضية 1) — عدد الصور التي سيتم توليدها لكل موجه. - generator (
torch.Generatorأوlist[torch.Generator]، اختياري) —torch.Generatorلجعل التوليد حتميًا. - latents (
torch.Tensor، اختياري) — كائنات latents ضجيجية مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات لتوليد الصور. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كائن latents عن طريق الاستخراج باستخدامgeneratorالعشوائي المُقدَّم. - 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بدلاً من tuple عادي. - attention_kwargs (
dict، اختياري) — قاموس kwargs يُمرَّر إلىAttentionProcessorإذا تم تحديده، كما هو معرَّف تحتself.processorفي diffusers.models.attention_processor. - 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، اختياري) — قائمة مدخلات المصفوفات (tensors) لدالةcallback_on_step_end. سيتم تمرير المصفوفات المحددة في القائمة كحجةcallback_kwargs. لن تتمكن من تضمين متغيرات غير مدرجة في خاصية._callback_tensor_inputsلفئة خط الأنابيب (pipeline) الخاص بك. - 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) — أدنى قيمة لسيجما للضوضاء المضافة إلى كامنات الصورة. - image_noise_sigma_max (
float، اختياري، القيمة الافتراضية0.135) — القيمة القصوى لسيجما للضوضاء المضافة إلى كامنات الصورة. - video (
PipelineImageInput، اختياري) — الفيديو المُدخل المستخدم لتكييف الفيديو إلى فيديو. - video_latents (
torch.Tensor، اختياري) — كائنات فيديو مُرمّزة مسبقًا لاستخدامها بدلًا منvideo. - add_noise_to_video_latents (
bool، اختياري، القيمة الافتراضيةTrue) — ما إذا كان يجب إضافة ضوضاء إلى كامنات الفيديو قبل إزالة الضوضاء. - video_noise_sigma_min (
float، اختياري، القيمة الافتراضية0.111) — أدنى قيمة لسيجما للضوضاء المضافة إلى كامنات الفيديو. - video_noise_sigma_max (
float، اختياري، القيمة الافتراضية0.135) — القيمة القصوى لسيجما للضوضاء المضافة إلى كامنات الفيديو. - 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]) — عدد خطوات الاستدلال لكل مرحلة من مراحل الهرم أثناء توليد المرحلة 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 حيث
العنصر الأول هو قائمة بالصور المولّدة والعنصر الثاني هو قائمة من قيم bool
تُشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى “غير آمن للعمل” (nsfw).
دالة الاستدعاء call لخط الأنابيب 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
< 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_embeds من معامل الإدخالnegative_prompt. - device — (
torch.device، اختياري): جهاز torch - dtype — (
torch.dtype، اختياري): نوع بيانات torch
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
HeliosPipelineOutput
فئة diffusers.pipelines.helios.pipeline_output.HeliosPipelineOutput
< source >( frames: Tensor )
المعاملات
- frames (
torch.Tensorأوnp.ndarrayأو List[List[PIL.Image.Image]]) — قائمة مخرجات الفيديو - يمكن أن تكون قائمة متداخلة بطولbatch_size,حيث تحتوي كل قائمة فرعية على سلاسل صور PIL منزوعة الضوضاء بطولnum_frames.كما يمكن أن تكون مصفوفة NumPy أو متجه Torch من الشكل(batch_size, num_frames, channels, height, width).
فئة الإخراج لخطوط أنابيب Helios.

