Buckets:
#
# مرخّص بموجب ترخيص Apache الإصدار 2.0 (المسمى "الترخيص")
# لا يجوز لك استخدام هذا الملف إلا وفقاً لشروط الترخيص.
# يمكنك الحصول على نسخة من الترخيص في
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ما لم يقتضِ ذلك القانون المعمول به أو ما اتُّفق عليه كتابياً، البرمجيات
# تُوزَّع بموجب الرخصة على أساس "كما هي"،
# بلا أي ضمانات أو شروط من أي نوع، سواء صريحة أو ضمنية.
# راجع الترخيص لمعرفة اللغة المحددة التي تحكم الصلاحيات و
# قيود بموجب الترخيص. -->
# Cosmos
[منصة نموذج الأساس الكوني Cosmos للذكاء الاصطناعي الفيزيائي](https://huggingface.co/papers/2501.03575) من NVIDIA.
*يتطلب الذكاء الاصطناعي المادي أن يُدرَّب رقميًا أولًا. فهو يحتاج إلى توأم رقمي لنفسه، وهو نموذج السياسة، وتوأم رقمي للعالم، وهو نموذج العالم. في هذه الورقة، نقدم منصة نماذج الأساس للعالم (Cosmos World Foundation Model Platform) لمساعدة المطورين على بناء نماذج عالم مخصصة لإعدادات الذكاء الاصطناعي المادي الخاصة بهم. نضع نموذج الأساس للعالم كنموذج عالم ذي استخدام عام يمكن ضبطه بدقة ليصبح نموذج عالم مخصصًا للتطبيقات اللاحقة. تغطي منصتنا خط أنابيب لفرز الفيديو، ونماذج أساس للعالم مُدرَّبة مسبقًا، وأمثلة على التدريب اللاحق لنماذج الأساس للعالم المُدرَّبة مسبقًا، ومُرمِّزات رموز الفيديو. وللمساعدة في حل أكثر مشاكل مجتمعنا إلحاحًا، نجعل منصتنا مفتوحة المصدر ونماذجنا مفتوحة الأوزان مع تراخيص سائبة متاحة عبر https://github.com/NVIDIA/Cosmos.*
> [!TIP]
> تأكد من الاطلاع على [دليل المجدولين](../../using-diffusers/schedulers) لمعرفة كيفية استكشاف التوازن بين سرعة المجدول وجودة النتائج، واطّلع على قسم [إعادة استخدام المكونات عبر خطوط الأنابيب](../../using-diffusers/loading#reusing-models-in-multiple-pipelines) لمعرفة كيفية تحميل نفس المكونات بكفاءة في خطوط أنابيب متعددة.
## الاستخدام الأساسي
```python
import torch
from diffusers import Cosmos2_5_PredictBasePipeline
from diffusers.utils import export_to_video
model_id = "nvidia/Cosmos-Predict2.5-2B"
pipe = Cosmos2_5_PredictBasePipeline.from_pretrained(
model_id, revision="diffusers/base/post-trained", dtype=torch.bfloat16
)
pipe.to("cuda") # or "mps", "xpu", "cpu"
prompt = "As the red light shifts to green, the red bus at the intersection begins to move forward, its headlights cutting through the falling snow. The snowy tire tracks deepen as the vehicle inches ahead, casting fresh lines onto the slushy road. Around it, streetlights glow warmer, illuminating the drifting flakes and wet reflections on the asphalt. Other cars behind start to edge forward, their beams joining the scene. The stillness of the urban street transitions into motion as the quiet snowfall is punctuated by the slow advance of traffic through the frosty city corridor."
negative_prompt = "The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality."
output = pipe(
image=None,
video=None,
prompt=prompt,
negative_prompt=negative_prompt,
num_frames=93,
generator=torch.Generator().manual_seed(1),
).frames[0]
export_to_video(output, "text2world.mp4", fps=16)
```
## Cosmos2_5_TransferPipeline[[diffusers.Cosmos2_5_TransferPipeline]]
#### diffusers.Cosmos2_5_TransferPipeline[[diffusers.Cosmos2_5_TransferPipeline]]
```python
diffusers.Cosmos2_5_TransferPipeline(text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: AutoTokenizer, transformer: CosmosTransformer3DModel, vae: AutoencoderKLWan, scheduler: UniPCMultistepScheduler, controlnet: CosmosControlNetModel, safety_checker: typing.Optional[diffusers.pipelines.cosmos.pipeline_cosmos2_5_transfer.CosmosSafetyChecker] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_transfer.py#L152)
**المعاملات:**
text_encoder (`Qwen2_5_VLForConditionalGeneration`) : مُشفِّر نص ثابت. يستخدم Cosmos Transfer2.5 مُشفِّر [Qwen2.5 VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct).
tokenizer (`AutoTokenizer`) : مُجزِّئ (Tokenizer) مرتبط بمُشفِّر (encoder) نموذج Qwen2.5 VL.
transformer ([CosmosTransformer3DModel](/docs/diffusers/main/ar/api/models/cosmos_transformer3d#diffusers.CosmosTransformer3DModel)) : نموذج Transformer مشروط لإزالة الضوضاء من الكامنات (latents) المُرمّزة للصور.
scheduler ([UniPCMultistepScheduler](/docs/diffusers/main/ar/api/schedulers/unipc#diffusers.UniPCMultistepScheduler)) : مُجدول يُستخدم بالاقتران مع `transformer` لإزالة الضوضاء من كامنات الصورة المُرمّزة.
vae ([AutoencoderKLWan](/docs/diffusers/main/ar/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan)) : نموذج الترميز التحويلي التبايني (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
controlnet (`CosmosControlNetModel`) : ControlNet المستخدم لتكييف التوليد على مدخلات التحكم.
خط أنابيب لنموذج Cosmos Transfer2.5، يدعم الاستدلال التلقائي التتابعي.
يرث هذا النموذج من [DiffusionPipeline](/docs/diffusers/main/ar/api/pipelines/overview#diffusers.DiffusionPipeline). راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
#### __call__[[diffusers.Cosmos2_5_TransferPipeline.__call__]]
```python
__call__(controls: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], typing.List[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]]], controls_conditioning_scale: typing.Union[float, typing.List[float]] = 1.0, prompt: typing.Union[str, typing.List[str], NoneType] = None, negative_prompt: typing.Union[str, typing.List[str]] = 'The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality.', height: int = 704, width: typing.Optional[int] = None, num_frames: typing.Optional[int] = None, num_frames_per_chunk: int = 93, num_inference_steps: int = 36, guidance_scale: float = 3.0, num_videos_per_prompt: int = 1, generator: typing.Union[torch.Generator, typing.List[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: typing.Optional[str] = 'pil', return_dict: bool = True, callback_on_step_end: typing.Union[typing.Callable[[int, int, typing.Dict], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: typing.List[str] = ['latents'], max_sequence_length: int = 512, conditional_frame_timestep: float = 0.1, num_ar_conditional_frames: typing.Optional[int] = 1, num_ar_latent_conditional_frames: typing.Optional[int] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_transfer.py#L569)
**المعاملات:**
controls (`PipelineImageInput`، `List[PipelineImageInput]`) : صورة أو فيديو إدخال للتحكم تُستخدم بواسطة ControlNet.
controls_conditioning_scale (`float` أو `List[float]`، *اختياري*، القيمة الافتراضية `1.0`) : عامل/عوامل المقياس لمخرجات ControlNet. يتم بث قيمة float واحدة إلى جميع كتل التحكم.
prompt (`str` أو `List[str]`، *اختياري*) : الأمر أو الأوامر التي تُوجّه عملية التوليد. مطلوب ما لم يُقدَّم `prompt_embeds`.
negative_prompt (`str` أو `List[str]`، *اختياري*) : الأمر أو الأوامر التي لا ينبغي أن توجّه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `negative_prompt_embeds` بدلاً من ذلك. يُتجاهل عند عدم استخدام التوجيه (أي يُتجاهل إذا لم يكن `guidance_scale` أكبر من `1`).
height (`int`، القيمة الافتراضية `704`) : ارتفاع الصورة المولّدة بالبكسل.
width (`int`, *اختياري*) : عرض الصورة المولدة بالبكسل. إذا لم يُقدَّم، فسيتم تحديده بناءً على نسبة أبعاد الإدخال والارتفاع المقدم.
num_frames (`int`, *اختياري*) : عدد الإطارات المُخرَجة. القيمة الافتراضية هي `None` لإخراج عدد إطارات مطابق لعدد إطارات الإدخال `controls`.
num_frames_per_chunk (`int`، *اختياري*، القيمة الافتراضية `93`) : عدد الإطارات المولّدة لكل كتلة توليد ذاتي. عندما يتجاوز العدد الإجمالي للإطارات هذه القيمة، يتم تقسيم التوليد إلى عدة كتل باستخدام نهج النافذة المنزلقة.
num_inference_steps (`int`، القيمة الافتراضية `36`) : عدد خطوات إزالة الضوضاء. تؤدي زيادة عدد خطوات إزالة الضوضاء عادةً إلى صورة ذات جودة أعلى على حساب بطء الاستدلال.
guidance_scale (`float`، القيمة الافتراضية `3.0`) : مقياس التوجيه كما هو معرّف في [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). يُعرَّف `guidance_scale` على أنه `w` من المعادلة 2. في [Imagen Paper](https://huggingface.co/papers/2205.11487). يتم تفعيل مقياس التوجيه عن طريق تعيين `guidance_scale > 1`.
num_videos_per_prompt (`int`، *اختياري*، القيمة الافتراضية 1) : عدد الصور التي سيتم توليدها لكل موجه.
generator (`torch.Generator` أو `List[torch.Generator]`، *اختياري*) : [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) لجعل التوليد حتميًا.
latents (`torch.Tensor`، *اختياري*) : كامنات ضجيج مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كامنات من خلال الاستخراج باستخدام `generator` العشوائي المُقدَّم.
prompt_embeds (`torch.Tensor`، *اختياري*) : تمثيلات نصية مُولّدة مسبقًا. يمكن استخدامها لتعديل مدخلات النص بسهولة، *مثلًا* وزن الأوامر. إذا لم تُقدَّم، فسيتم توليد تمثيلات النص من معامل الإدخال `prompt`.
negative_prompt_embeds (`torch.FloatTensor`، *اختياري*) : تمثيلات نصية سالبة مُولّدة مسبقًا. بالنسبة إلى PixArt-Sigma، يجب أن يكون هذا الأمر السلبي "". إذا لم يُقدَّم، فسيتم توليد negative_prompt_embeds من معامل الإدخال `negative_prompt`.
output_type (`str`، *اختياري*، الافتراضي `"pil"`) : صيغة الصورة المولّدة. اختر بين `PIL.Image` أو `np.array`.
return_dict (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان يجب إرجاع `CosmosPipelineOutput` بدلاً من tuple عادي.
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`) : الحد الأقصى لعدد الرموز في الاستعلام. إذا تجاوز الاستعلام هذا الطول، فسيتم اقتطاعه. وإذا كان الاستعلام أقصر من هذا الطول، فسيتم ملؤه.
conditional_frame_timestep (`float`، *اختياري*، القيمة الافتراضية 0.1) : قيمة الخطوة الزمنية المستخدمة للإطارات الشرطية أثناء إزالة الضوضاء. يجب أن تكون ضمن الفترة `[0, 1]`.
num_ar_conditional_frames (`int`، *اختياري*، القيمة الافتراضية `1`) : عدد الإطارات التي تُشترط على حلقات الاستدلال اللاحقة في الاستدلال التلقائي التتابعي، أي بدءًا من المقطع الثاني وما بعده. يُستخدم فقط إذا كانت `num_ar_latent_conditional_frames` تساوي `None`. يُستخدم هذا فقط عند تنفيذ الاستدلال التلقائي التتابعي، أي عندما يكون عدد الإطارات في عناصر التحكم > num_frames_per_chunk
num_ar_latent_conditional_frames (`int`, *اختياري*) : عدد الإطارات الكامنة التي تُشترط على حلقات الاستدلال اللاحقة في الاستدلال التلقائي التتابعي، أيً للقطعة الثانية وما بعدها. يُستخدم فقط إذا كان `num_ar_conditional_frames` هو `None`. يُستخدم هذا فقط عند تنفيذ الاستدلال التلقائي التتابعي، أيً عندما يكون عدد الإطارات في الضوابط > num_frames_per_chunk
**يعيد:** `~CosmosPipelineOutput` أو `tuple`
إذا كان `return_dict` هو `True`، يُعاد `CosmosPipelineOutput`، وإلا يُعاد `tuple` حيث يكون العنصر الأول قائمة بالصور المولّدة والعنصر الثاني قائمة من قيم `bool` تشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى "غير آمن للعمل" (nsfw).
`controls` هي التي تُدير عملية التكييف عبر ControlNet. ويُفترض أن تكون عناصر التحكم مُعالجة مسبقًا، على سبيل المثال تكون خرائط الحواف محسوبة مسبقًا.
سيؤدي تعيين `num_frames` إلى تقييد إجمالي عدد الإطارات المُخرَجة، أما إذا لم يُقدَّم أو تم تعيينه إلى None (الافتراضي) فسيطابق عدد الإطارات المُخرَجة عدد إطارات الإدخال `controls`.
يُؤيَّد الاستدلال التلقائي التتابعي، ولذلك تُستخدم نافذة منزلقة من `num_frames_per_chunk` إطارات في كل حلقة إزالة الضوضاء. بالإضافة إلى ذلك، عند تنفيذ الاستدلال التلقائي التتابعي، تُستخدم الإطارات السابقة `num_ar_latent_conditional_frames` أو `num_ar_conditional_frames` لتكييف حلقات الاستدلال لإزالة الضوضاء التالية.
أمثلة:
```python
>>> import cv2
>>> import numpy as np
>>> from PIL import Image
>>> import torch
>>> from diffusers import Cosmos2_5_TransferPipeline, AutoModel
>>> from diffusers.utils import export_to_video, load_video
>>> model_id = "nvidia/Cosmos-Transfer2.5-2B"
>>> # Load a Transfer2.5 controlnet variant (edge, depth, seg, or blur)
>>> controlnet = AutoModel.from_pretrained(
... model_id, revision="diffusers/controlnet/general/edge", torch_dtype=torch.bfloat16
... )
>>> pipe = Cosmos2_5_TransferPipeline.from_pretrained(
... model_id, controlnet=controlnet, revision="diffusers/general", torch_dtype=torch.bfloat16
... )
>>> pipe = pipe.to("cuda")
>>> # Video2World with edge control: Generate video guided by edge maps extracted from input video.
>>> prompt = (
... "The video is a demonstration of robotic manipulation, likely in a laboratory or testing environment. It"
... "features two robotic arms interacting with a piece of blue fabric. The setting is a room with a beige"
... "couch in the background, providing a neutral backdrop for the robotic activity. The robotic arms are"
... "positioned on either side of the fabric, which is placed on a yellow cushion. The left robotic arm is"
... "white with a black gripper, while the right arm is black with a more complex, articulated gripper. At the"
... "beginning, the fabric is laid out on the cushion. The left robotic arm approaches the fabric, its gripper"
... "opening and closing as it positions itself. The right arm remains stationary initially, poised to assist."
... "As the video progresses, the left arm grips the fabric, lifting it slightly off the cushion. The right arm"
... "then moves in, its gripper adjusting to grasp the opposite side of the fabric. Both arms work in"
... "coordination, lifting and holding the fabric between them. The fabric is manipulated with precision,"
... "showcasing the dexterity and control of the robotic arms. The camera remains static throughout, focusing"
... "on the interaction between the robotic arms and the fabric, allowing viewers to observe the detailed"
... "movements and coordination involved in the task."
... )
>>> negative_prompt = (
... "The video captures a series of frames showing ugly scenes, static with no motion, motion blur, "
... "over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, "
... "underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky "
... "movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, "
... "fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. "
... "Overall, the video is of poor quality."
... )
>>> input_video = load_video(
... "https://github.com/nvidia-cosmos/cosmos-transfer2.5/raw/refs/heads/main/assets/robot_example/robot_input.mp4"
... )
>>> num_frames = 93
>>> # Extract edge maps from the input video using Canny edge detection
>>> edge_maps = [
... cv2.Canny(cv2.cvtColor(np.array(frame.convert("RGB")), cv2.COLOR_RGB2BGR), 100, 200)
... for frame in input_video[:num_frames]
... ]
>>> edge_maps = np.stack(edge_maps)[None] # (T, H, W) -> (1, T, H, W)
>>> controls = torch.from_numpy(edge_maps).expand(3, -1, -1, -1) # (1, T, H, W) -> (3, T, H, W)
>>> controls = [Image.fromarray(x.numpy()) for x in controls.permute(1, 2, 3, 0)]
>>> export_to_video(controls, "edge_controlled_video_edge.mp4", fps=30)
>>> # Transfer inference with controls.
>>> video = pipe(
... controls=controls,
... controls_conditioning_scale=1.0,
... prompt=prompt,
... negative_prompt=negative_prompt,
... num_frames=num_frames,
... ).frames[0]
>>> export_to_video(video, "edge_controlled_video.mp4", fps=30)
```
#### encode_prompt[[diffusers.Cosmos2_5_TransferPipeline.encode_prompt]]
```python
encode_prompt(prompt: typing.Union[str, typing.List[str]], negative_prompt: typing.Union[str, typing.List[str], NoneType] = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_transfer.py#L296)
**المعاملات:**
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 dtype
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
## Cosmos2_5_PredictBasePipeline[[diffusers.Cosmos2_5_PredictBasePipeline]]
#### diffusers.Cosmos2_5_PredictBasePipeline[[diffusers.Cosmos2_5_PredictBasePipeline]]
```python
diffusers.Cosmos2_5_PredictBasePipeline(text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: AutoTokenizer, transformer: CosmosTransformer3DModel, vae: AutoencoderKLWan, scheduler: UniPCMultistepScheduler, safety_checker: CosmosSafetyChecker = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_predict.py#L185)
**المعاملات:**
text_encoder (`Qwen2_5_VLForConditionalGeneration`) : مُشفِّر نص ثابت. يستخدم Cosmos Predict2.5 مُشفِّر [Qwen2.5 VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct).
tokenizer (`AutoTokenizer`) : مُجزِّئ (Tokenizer) مرتبط بمُشفِّر (encoder) نموذج Qwen2.5 VL.
transformer ([CosmosTransformer3DModel](/docs/diffusers/main/ar/api/models/cosmos_transformer3d#diffusers.CosmosTransformer3DModel)) : نموذج Transformer مشروط لإزالة الضوضاء من الكامنات (latents) المُرمّزة للصور.
scheduler ([UniPCMultistepScheduler](/docs/diffusers/main/ar/api/schedulers/unipc#diffusers.UniPCMultistepScheduler)) : مُجدول يُستخدم بالاقتران مع `transformer` لإزالة الضوضاء من كامنات الصورة المُرمّزة.
vae ([AutoencoderKLWan](/docs/diffusers/main/ar/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan)) : نموذج الترميز التحويلي التبايني (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
خط أنابيب لنموذج [Cosmos Predict2.5](https://github.com/nvidia-cosmos/cosmos-predict2.5) الأساسي.
يرث هذا النموذج من [DiffusionPipeline](/docs/diffusers/main/ar/api/pipelines/overview#diffusers.DiffusionPipeline). راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
#### __call__[[diffusers.Cosmos2_5_PredictBasePipeline.__call__]]
```python
__call__(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], NoneType] = None, video: list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] | None = None, prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, height: int = 704, width: int = 1280, num_frames: int = 93, num_inference_steps: int = 36, guidance_scale: float = 7.0, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Optional[typing.Callable[[int, int, NoneType], diffusers.callbacks.PipelineCallback | diffusers.callbacks.MultiPipelineCallbacks]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512, conditional_frame_timestep: float = 0.0001, num_latent_conditional_frames: int = 2)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_predict.py#L544)
**المعاملات:**
image (`PIL.Image.Image`، `np.ndarray`، `torch.Tensor`، *اختياري*) : صورة واحدة اختيارية لتكييف Image2World. يجب أن تكون `None` عند توفير `video`.
video (`list[PIL.Image.Image]`، `np.ndarray`، `torch.Tensor`، *اختياري*) : فيديو إدخال اختياري لتكييف Video2World. يجب أن يكون `None` عند تقديم `image`.
prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي تُوجّه عملية التوليد. مطلوب ما لم يُقدَّم `prompt_embeds`.
negative_prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي لا ينبغي أن توجه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `negative_prompt_embeds` بدلاً من ذلك. يتم تجاهله عند عدم استخدام التوجيه (أي يُتجاهل إذا لم يكن `guidance_scale` أكبر من `1`).
height (`int`، القيمة الافتراضية `704`) : ارتفاع الصورة المولّدة بالبكسل.
width (`int`، القيمة الافتراضية `1280`) : عرض الصورة المولدة بالبكسل.
num_frames (`int`، القيمة الافتراضية `93`) : عدد الإطارات الناتجة. استخدم `93` لتوليد العالم (الفيديو)؛ اضبطها على `1` لإرجاع إطار واحد.
num_inference_steps (`int`، القيمة الافتراضية `35`) : عدد خطوات إزالة الضوضاء. تؤدي زيادة عدد خطوات إزالة الضوضاء عادةً إلى صورة ذات جودة أعلى على حساب بطء الاستدلال.
guidance_scale (`float`، القيمة الافتراضية `7.0`) : مقياس التوجيه كما هو معرّف في [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). يُعرَّف `guidance_scale` على أنه `w` من المعادلة 2. في [Imagen Paper](https://huggingface.co/papers/2205.11487). يتم تفعيل مقياس التوجيه عن طريق تعيين `guidance_scale > 1`.
num_videos_per_prompt (`int`، *اختياري*، القيمة الافتراضية 1) : عدد الصور التي سيتم توليدها لكل موجه.
generator (`torch.Generator` أو `list[torch.Generator]`، *اختياري*) : [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) لجعل التوليد حتميًا.
latents (`torch.Tensor`، *اختياري*) : كامنات ضجيج مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات لتوليد الصور. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كامنات من خلال الاستخراج باستخدام `generator` العشوائي المُقدَّم.
prompt_embeds (`torch.Tensor`، *اختياري*) : تمثيلات نصية مُولّدة مسبقًا. يمكن استخدامها لتعديل مدخلات النص بسهولة، *مثلًا* وزن الأوامر. إذا لم تُقدَّم، فسيتم توليد تمثيلات النص من معامل الإدخال `prompt`.
negative_prompt_embeds (`torch.FloatTensor`، *اختياري*) : تمثيلات نصية سالبة مُولّدة مسبقًا. بالنسبة إلى PixArt-Sigma، يجب أن يكون هذا الأمر السلبي "". إذا لم يُقدَّم، فسيتم توليد negative_prompt_embeds من معامل الإدخال `negative_prompt`.
output_type (`str`، *اختياري*، الافتراضي `"pil"`) : صيغة الصورة المولّدة. اختر بين `PIL.Image` أو `np.array`.
return_dict (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان يجب إرجاع `CosmosPipelineOutput` بدلاً من tuple عادي.
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`) : الحد الأقصى لعدد الرموز في الاستعلام. إذا تجاوز الاستعلام هذا الطول، فسيتم اقتطاعه. وإذا كان الاستعلام أقصر من هذا الطول، فسيتم ملؤه.
num_latent_conditional_frames (`int`، القيمة الافتراضية `2`) : عدد الإطارات الشرطية الكامنة المستخدمة لتكييف Video2World. يتم حساب عدد إطارات البكسل المستخرجة من الفيديو المدخل على النحو التالي `4 * (num_latent_conditional_frames - 1) + 1`. اضبطه على 1 للحصول على سلوك مشابه لـ Image2World (تكييف إطار واحد).
conditional_frame_timestep (`float`، *اختياري*، القيمة الافتراضية 0.0001) : قيمة خطوة الزمن المستخدمة للإطارات الشرطية أثناء إزالة الضوضاء.
**يعيد:** `~CosmosPipelineOutput` أو `tuple`
إذا كان `return_dict` هو `True`، يُعاد `CosmosPipelineOutput`، وإلا يُعاد `tuple` حيث يكون العنصر الأول قائمة بالصور المولّدة والعنصر الثاني قائمة من قيم `bool` تشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى "غير آمن للعمل" (nsfw).
دالة الاستدعاء call لخط الأنابيب pipeline الخاص بالتوليد. تدعم ثلاثة أوضاع:
- **Text2World**: `image=None`، `video=None`، تم توفير `prompt`. يولّد مقطعًا من العالم.
- **Image2World**: تم توفير `image`، `video=None`، وتم توفير `prompt`. شروط على إطار واحد.
- **Video2World**: يُوفَّر `video`، و`image=None`، ويُوفَّر `prompt`. شروط على مقطع الإدخال.
اضبط `num_frames=93` (الافتراضي) لإنتاج فيديو عالمي، أو `num_frames=1` لإنتاج إطار صورة واحد (الأسلوب المذكور أعلاه في "وضع *2Image").
تتبع المخرجات `output_type` (على سبيل المثال، يعيد `"pil"` قائمة من `num_frames` صور PIL لكل موجه).
أمثلة:
```python
>>> import torch
>>> from diffusers import Cosmos2_5_PredictBasePipeline
>>> from diffusers.utils import export_to_video, load_image, load_video
>>> model_id = "nvidia/Cosmos-Predict2.5-2B"
>>> pipe = Cosmos2_5_PredictBasePipeline.from_pretrained(
... model_id, revision="diffusers/base/post-trained", torch_dtype=torch.bfloat16
... )
>>> pipe = pipe.to("cuda")
>>> # Common negative prompt reused across modes.
>>> negative_prompt = (
... "The video captures a series of frames showing ugly scenes, static with no motion, motion blur, "
... "over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, "
... "underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky "
... "movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, "
... "fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. "
... "Overall, the video is of poor quality."
... )
>>> # Text2World: generate a 93-frame world video from text only.
>>> prompt = (
... "As the red light shifts to green, the red bus at the intersection begins to move forward, its headlights "
... "cutting through the falling snow. The snowy tire tracks deepen as the vehicle inches ahead, casting fresh "
... "lines onto the slushy road. Around it, streetlights glow warmer, illuminating the drifting flakes and wet "
... "reflections on the asphalt. Other cars behind start to edge forward, their beams joining the scene. "
... "The stillness of the urban street transitions into motion as the quiet snowfall is punctuated by the slow "
... "advance of traffic through the frosty city corridor."
... )
>>> video = pipe(
... image=None,
... video=None,
... prompt=prompt,
... negative_prompt=negative_prompt,
... num_frames=93,
... generator=torch.Generator().manual_seed(1),
... ).frames[0]
>>> export_to_video(video, "text2world.mp4", fps=16)
>>> # Image2World: condition on a single image and generate a 93-frame world video.
>>> prompt = (
... "A high-definition video captures the precision of robotic welding in an industrial setting. "
... "The first frame showcases a robotic arm, equipped with a welding torch, positioned over a large metal structure. "
... "The welding process is in full swing, with bright sparks and intense light illuminating the scene, creating a vivid "
... "display of blue and white hues. A significant amount of smoke billows around the welding area, partially obscuring "
... "the view but emphasizing the heat and activity. The background reveals parts of the workshop environment, including a "
... "ventilation system and various pieces of machinery, indicating a busy and functional industrial workspace. As the video "
... "progresses, the robotic arm maintains its steady position, continuing the welding process and moving to its left. "
... "The welding torch consistently emits sparks and light, and the smoke continues to rise, diffusing slightly as it moves upward. "
... "The metal surface beneath the torch shows ongoing signs of heating and melting. The scene retains its industrial ambiance, with "
... "the welding sparks and smoke dominating the visual field, underscoring the ongoing nature of the welding operation."
... )
>>> image = load_image(
... "https://media.githubusercontent.com/media/nvidia-cosmos/cosmos-predict2.5/refs/heads/main/assets/base/robot_welding.jpg"
... )
>>> video = pipe(
... image=image,
... video=None,
... prompt=prompt,
... negative_prompt=negative_prompt,
... num_frames=93,
... generator=torch.Generator().manual_seed(1),
... ).frames[0]
>>> export_to_video(video, "image2world.mp4", fps=16)
>>> # Video2World: condition on an input clip and predict a 93-frame world video.
>>> prompt = (
... "The video opens with an aerial view of a large-scale sand mining construction operation, showcasing extensive piles "
... "of brown sand meticulously arranged in parallel rows. A central water channel, fed by a water pipe, flows through the "
... "middle of these sand heaps, creating ripples and movement as it cascades down. The surrounding area features dense green "
... "vegetation on the left, contrasting with the sandy terrain, while a body of water is visible in the background on the right. "
... "As the video progresses, a piece of heavy machinery, likely a bulldozer, enters the frame from the right, moving slowly along "
... "the edge of the sand piles. This machinery's presence indicates ongoing construction work in the operation. The final frame "
... "captures the same scene, with the water continuing its flow and the bulldozer still in motion, maintaining the dynamic yet "
... "steady pace of the construction activity."
... )
>>> input_video = load_video(
... "https://github.com/nvidia-cosmos/cosmos-predict2.5/raw/refs/heads/main/assets/base/sand_mining.mp4"
... )
>>> video = pipe(
... image=None,
... video=input_video,
... prompt=prompt,
... negative_prompt=negative_prompt,
... num_frames=93,
... generator=torch.Generator().manual_seed(1),
... ).frames[0]
>>> export_to_video(video, "video2world.mp4", fps=16)
>>> # To produce an image instead of a world (video) clip, set num_frames=1 and
>>> # save the first frame: pipe(..., num_frames=1).frames[0][0].
```
#### encode_prompt[[diffusers.Cosmos2_5_PredictBasePipeline.encode_prompt]]
```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_predict.py#L324)
**المعاملات:**
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 dtype
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
## CosmosTextToWorldPipeline[[diffusers.CosmosTextToWorldPipeline]]
#### diffusers.CosmosTextToWorldPipeline[[diffusers.CosmosTextToWorldPipeline]]
```python
diffusers.CosmosTextToWorldPipeline(text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: CosmosTransformer3DModel, vae: AutoencoderKLCosmos, scheduler: EDMEulerScheduler, safety_checker: CosmosSafetyChecker = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos_text2world.py#L140)
**المعاملات:**
text_encoder (`T5EncoderModel`) : مُشفِّر نص ثابت. يستخدم Cosmos [T5](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel)؛ وتحديداً النسخة [t5-11b](https://huggingface.co/google-t5/t5-11b).
tokenizer (`T5TokenizerFast`) : مُجزِّئ من الفئة [T5Tokenizer](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Tokenizer).
transformer ([CosmosTransformer3DModel](/docs/diffusers/main/ar/api/models/cosmos_transformer3d#diffusers.CosmosTransformer3DModel)) : نموذج Transformer مشروط لإزالة الضوضاء من الكامنات (latents) المُرمّزة للصور.
scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ar/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : مُجدوِل يُستخدم بالاقتران مع `transformer` لإزالة الضوضاء من كامنات الصورة المُرمَّزة.
vae ([AutoencoderKLCosmos](/docs/diffusers/main/ar/api/models/autoencoderkl_cosmos#diffusers.AutoencoderKLCosmos)) : نموذج الترميز التحويلي التبايني (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
خط أنابيب لتوليد النص إلى عالم باستخدام [Cosmos Predict1](https://github.com/nvidia-cosmos/cosmos-predict1).
يرث هذا النموذج من [DiffusionPipeline](/docs/diffusers/main/ar/api/pipelines/overview#diffusers.DiffusionPipeline). راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
#### __call__[[diffusers.CosmosTextToWorldPipeline.__call__]]
```python
__call__(prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 704, width: int = 1280, num_frames: int = 121, num_inference_steps: int = 36, guidance_scale: float = 7.0, fps: int = 30, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos_text2world.py#L401)
**المعاملات:**
prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي تُوجّه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `prompt_embeds` بدلاً من ذلك.
negative_prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي لا ينبغي أن توجه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `negative_prompt_embeds` بدلاً من ذلك. يتم تجاهله عند عدم استخدام التوجيه (أي يُتجاهل إذا لم يكن `guidance_scale` أكبر من `1`).
height (`int`، القيمة الافتراضية `720`) : ارتفاع الصورة المولّدة بالبكسل.
width (`int`، القيمة الافتراضية `1280`) : عرض الصورة المولدة بالبكسل.
num_frames (`int`، القيمة الافتراضية `121`) : عدد الإطارات في الفيديو المولّد.
num_inference_steps (`int`، القيمة الافتراضية `36`) : عدد خطوات إزالة الضوضاء. تؤدي زيادة عدد خطوات إزالة الضوضاء عادةً إلى صورة ذات جودة أعلى على حساب بطء الاستدلال.
guidance_scale (`float`، القيمة الافتراضية `7.0`) : مقياس التوجيه كما هو معرّف في [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). يُعرَّف `guidance_scale` على أنه `w` من المعادلة 2. في [Imagen Paper](https://huggingface.co/papers/2205.11487). يتم تفعيل مقياس التوجيه عن طريق تعيين `guidance_scale > 1`.
fps (`int`، القيمة الافتراضية `30`) : عدد الإطارات في الثانية للفيديو المولّد.
num_videos_per_prompt (`int`، *اختياري*، القيمة الافتراضية 1) : عدد الصور التي سيتم توليدها لكل موجه.
generator (`torch.Generator` أو `list[torch.Generator]`، *اختياري*) : [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) لجعل التوليد حتميًا.
latents (`torch.Tensor`، *اختياري*) : كامنات ضجيج مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات لتوليد الصور. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كامنات من خلال الاستخراج باستخدام `generator` العشوائي المُقدَّم.
prompt_embeds (`torch.Tensor`، *اختياري*) : تمثيلات نصية مُولّدة مسبقًا. يمكن استخدامها لتعديل مدخلات النص بسهولة، *مثلًا* وزن الأوامر. إذا لم تُقدَّم، فسيتم توليد تمثيلات النص من معامل الإدخال `prompt`.
negative_prompt_embeds (`torch.FloatTensor`، *اختياري*) : تمثيلات نصية سالبة مُولّدة مسبقًا. بالنسبة إلى PixArt-Sigma، يجب أن يكون هذا الأمر السلبي "". إذا لم يُقدَّم، فسيتم توليد negative_prompt_embeds من معامل الإدخال `negative_prompt`.
output_type (`str`، *اختياري*، الافتراضي `"pil"`) : صيغة الصورة المولّدة. اختر بين `PIL.Image` أو `np.array`.
return_dict (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان يجب إرجاع `CosmosPipelineOutput` بدلاً من tuple عادي.
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`) : الحد الأقصى لعدد الرموز في الاستعلام. إذا تجاوز الاستعلام هذا الطول، فسيتم اقتطاعه. وإذا كان الاستعلام أقصر من هذا الطول، فسيتم ملؤه.
**يعيد:** `~CosmosPipelineOutput` أو `tuple`
إذا كان `return_dict` هو `True`، يُعاد `CosmosPipelineOutput`، وإلا يُعاد `tuple` حيث يكون العنصر الأول قائمة بالصور المولّدة والعنصر الثاني قائمة من قيم `bool` تشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى "غير آمن للعمل" (nsfw).
دالة الاستدعاء call لخط الأنابيب pipeline الخاص بالتوليد.
أمثلة:
```python
>>> import torch
>>> from diffusers import CosmosTextToWorldPipeline
>>> from diffusers.utils import export_to_video
>>> model_id = "nvidia/Cosmos-1.0-Diffusion-7B-Text2World"
>>> pipe = CosmosTextToWorldPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> prompt = "A sleek, humanoid robot stands in a vast warehouse filled with neatly stacked cardboard boxes on industrial shelves. The robot's metallic body gleams under the bright, even lighting, highlighting its futuristic design and intricate joints. A glowing blue light emanates from its chest, adding a touch of advanced technology. The background is dominated by rows of boxes, suggesting a highly organized storage system. The floor is lined with wooden pallets, enhancing the industrial setting. The camera remains static, capturing the robot's poised stance amidst the orderly environment, with a shallow depth of field that keeps the focus on the robot while subtly blurring the background for a cinematic effect."
>>> output = pipe(prompt=prompt).frames[0]
>>> export_to_video(output, "output.mp4", fps=30)
```
#### encode_prompt[[diffusers.CosmosTextToWorldPipeline.encode_prompt]]
```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos_text2world.py#L239)
**المعاملات:**
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 dtype
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
## CosmosVideoToWorldPipeline[[diffusers.CosmosVideoToWorldPipeline]]
#### diffusers.CosmosVideoToWorldPipeline[[diffusers.CosmosVideoToWorldPipeline]]
```python
diffusers.CosmosVideoToWorldPipeline(text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: CosmosTransformer3DModel, vae: AutoencoderKLCosmos, scheduler: EDMEulerScheduler, safety_checker: CosmosSafetyChecker = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos_video2world.py#L181)
**المعاملات:**
text_encoder (`T5EncoderModel`) : مُشفِّر نص ثابت. يستخدم Cosmos [T5](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel)؛ وتحديداً النسخة [t5-11b](https://huggingface.co/google-t5/t5-11b).
tokenizer (`T5TokenizerFast`) : مُجزِّئ من الفئة [T5Tokenizer](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Tokenizer).
transformer ([CosmosTransformer3DModel](/docs/diffusers/main/ar/api/models/cosmos_transformer3d#diffusers.CosmosTransformer3DModel)) : نموذج Transformer مشروط لإزالة الضوضاء من الكامنات (latents) المُرمّزة للصور.
scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ar/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : مُجدوِل يُستخدم بالاقتران مع `transformer` لإزالة الضوضاء من كامنات الصورة المُرمَّزة.
vae ([AutoencoderKLCosmos](/docs/diffusers/main/ar/api/models/autoencoderkl_cosmos#diffusers.AutoencoderKLCosmos)) : نموذج الترميز التحويلي التبايني (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
خط أنابيب لتوليد العالم من الصور وتوليد العالم من الفيديو باستخدام [Cosmos Predict-1](https://github.com/nvidia-cosmos/cosmos-predict1).
يرث هذا النموذج من [DiffusionPipeline](/docs/diffusers/main/ar/api/pipelines/overview#diffusers.DiffusionPipeline). راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
#### __call__[[diffusers.CosmosVideoToWorldPipeline.__call__]]
```python
__call__(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]] = None, video: list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] = None, prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 704, width: int = 1280, num_frames: int = 121, num_inference_steps: int = 36, guidance_scale: float = 7.0, input_frames_guidance: bool = False, augment_sigma: float = 0.001, fps: int = 30, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos_video2world.py#L511)
**المعاملات:**
image (`PIL.Image.Image`، `np.ndarray`، `torch.Tensor`، *اختياري*) : الصورة التي سيتم استخدامها كمدخل شرطي لتوليد الفيديو.
video (`list[PIL.Image.Image]`، `np.ndarray`، `torch.Tensor`، *اختياري*) : الفيديو الذي سيُستخدم كمدخل تكييفي لتوليد الفيديو.
prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي تُوجّه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `prompt_embeds` بدلاً من ذلك.
negative_prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي لا ينبغي أن توجه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `negative_prompt_embeds` بدلاً من ذلك. يتم تجاهله عند عدم استخدام التوجيه (أي يُتجاهل إذا لم يكن `guidance_scale` أكبر من `1`).
height (`int`، القيمة الافتراضية `720`) : ارتفاع الصورة المولّدة بالبكسل.
width (`int`، القيمة الافتراضية `1280`) : عرض الصورة المولدة بالبكسل.
num_frames (`int`، القيمة الافتراضية `121`) : عدد الإطارات في الفيديو المولّد.
num_inference_steps (`int`، القيمة الافتراضية `36`) : عدد خطوات إزالة الضوضاء. تؤدي زيادة عدد خطوات إزالة الضوضاء عادةً إلى صورة ذات جودة أعلى على حساب بطء الاستدلال.
guidance_scale (`float`، القيمة الافتراضية `7.0`) : مقياس التوجيه كما هو معرّف في [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). يُعرَّف `guidance_scale` على أنه `w` من المعادلة 2. في [Imagen Paper](https://huggingface.co/papers/2205.11487). يتم تفعيل مقياس التوجيه عن طريق تعيين `guidance_scale > 1`.
input_frames_guidance (`bool`، *اختياري*، الافتراضي `False`) : ما إذا كان سيتم تطبيق التوجيه على إطارات الإدخال الشرطي.
augment_sigma (`float`، *اختياري*، القيمة الافتراضية 0.001) : قيمة سيغما المستخدمة لتعزيز الكامنات الشرطية أثناء إزالة الضوضاء.
fps (`int`، القيمة الافتراضية `30`) : عدد الإطارات في الثانية للفيديو المولّد.
num_videos_per_prompt (`int`، *اختياري*، القيمة الافتراضية 1) : عدد الصور التي سيتم توليدها لكل موجه.
generator (`torch.Generator` أو `list[torch.Generator]`، *اختياري*) : [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) لجعل التوليد حتميًا.
latents (`torch.Tensor`، *اختياري*) : كامنات ضجيج مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات لتوليد الصور. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كامنات من خلال الاستخراج باستخدام `generator` العشوائي المُقدَّم.
prompt_embeds (`torch.Tensor`، *اختياري*) : تمثيلات نصية مُولّدة مسبقًا. يمكن استخدامها لتعديل مدخلات النص بسهولة، *مثلًا* وزن الأوامر. إذا لم تُقدَّم، فسيتم توليد تمثيلات النص من معامل الإدخال `prompt`.
negative_prompt_embeds (`torch.FloatTensor`، *اختياري*) : تمثيلات نصية سالبة مُولّدة مسبقًا. بالنسبة إلى PixArt-Sigma، يجب أن يكون هذا الأمر السلبي "". إذا لم يُقدَّم، فسيتم توليد negative_prompt_embeds من معامل الإدخال `negative_prompt`.
output_type (`str`، *اختياري*، الافتراضي `"pil"`) : صيغة الصورة المولّدة. اختر بين `PIL.Image` أو `np.array`.
return_dict (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان يجب إرجاع `CosmosPipelineOutput` بدلاً من tuple عادي.
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`) : الحد الأقصى لعدد الرموز في الاستعلام. إذا تجاوز الاستعلام هذا الطول، فسيتم اقتطاعه. وإذا كان الاستعلام أقصر من هذا الطول، فسيتم ملؤه.
**يعيد:** `~CosmosPipelineOutput` أو `tuple`
إذا كان `return_dict` هو `True`، يُعاد `CosmosPipelineOutput`، وإلا يُعاد `tuple` حيث يكون العنصر الأول قائمة بالصور المولّدة والعنصر الثاني قائمة من قيم `bool` تشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى "غير آمن للعمل" (nsfw).
دالة الاستدعاء call لخط الأنابيب pipeline الخاص بالتوليد.
أمثلة:
التحكم بالصور:
```python
>>> import torch
>>> from diffusers import CosmosVideoToWorldPipeline
>>> from diffusers.utils import export_to_video, load_image
>>> model_id = "nvidia/Cosmos-1.0-Diffusion-7B-Video2World"
>>> pipe = CosmosVideoToWorldPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> prompt = "The video depicts a long, straight highway stretching into the distance, flanked by metal guardrails. The road is divided into multiple lanes, with a few vehicles visible in the far distance. The surrounding landscape features dry, grassy fields on one side and rolling hills on the other. The sky is mostly clear with a few scattered clouds, suggesting a bright, sunny day."
>>> image = load_image(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cosmos/cosmos-video2world-input.jpg"
... )
>>> video = pipe(image=image, prompt=prompt).frames[0]
>>> export_to_video(video, "output.mp4", fps=30)
```
شرط الفيديو:
```python
>>> import torch
>>> from diffusers import CosmosVideoToWorldPipeline
>>> from diffusers.utils import export_to_video, load_video
>>> model_id = "nvidia/Cosmos-1.0-Diffusion-7B-Video2World"
>>> pipe = CosmosVideoToWorldPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe.transformer = torch.compile(pipe.transformer)
>>> pipe.to("cuda")
>>> prompt = "The video depicts a winding mountain road covered in snow, with a single vehicle traveling along it. The road is flanked by steep, rocky cliffs and sparse vegetation. The landscape is characterized by rugged terrain and a river visible in the distance. The scene captures the solitude and beauty of a winter drive through a mountainous region."
>>> video = load_video(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cosmos/cosmos-video2world-input-vid.mp4"
... )[:21] # This example uses only the first 21 frames
>>> video = pipe(video=video, prompt=prompt).frames[0]
>>> export_to_video(video, "output.mp4", fps=30)
```
#### encode_prompt[[diffusers.CosmosVideoToWorldPipeline.encode_prompt]]
```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos_video2world.py#L283)
**المعاملات:**
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 dtype
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
## Cosmos2TextToImagePipeline[[diffusers.Cosmos2TextToImagePipeline]]
#### diffusers.Cosmos2TextToImagePipeline[[diffusers.Cosmos2TextToImagePipeline]]
```python
diffusers.Cosmos2TextToImagePipeline(text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: CosmosTransformer3DModel, vae: AutoencoderKLWan, scheduler: FlowMatchEulerDiscreteScheduler, safety_checker: CosmosSafetyChecker = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_text2image.py#L143)
**المعاملات:**
text_encoder (`T5EncoderModel`) : مُشفِّر نص ثابت. يستخدم Cosmos [T5](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel)؛ وتحديداً النسخة [t5-11b](https://huggingface.co/google-t5/t5-11b).
tokenizer (`T5TokenizerFast`) : مُجزِّئ من الفئة [T5Tokenizer](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Tokenizer).
transformer ([CosmosTransformer3DModel](/docs/diffusers/main/ar/api/models/cosmos_transformer3d#diffusers.CosmosTransformer3DModel)) : نموذج Transformer مشروط لإزالة الضوضاء من الكامنات (latents) المُرمّزة للصور.
scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ar/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : مُجدوِل يُستخدم بالاقتران مع `transformer` لإزالة الضوضاء من كامنات الصورة المُرمَّزة.
vae ([AutoencoderKLWan](/docs/diffusers/main/ar/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan)) : نموذج الترميز التحويلي التبايني (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
خط أنابيب لتوليد الصور من النص باستخدام [Cosmos Predict2](https://github.com/nvidia-cosmos/cosmos-predict2).
يرث هذا النموذج من [DiffusionPipeline](/docs/diffusers/main/ar/api/pipelines/overview#diffusers.DiffusionPipeline). راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
#### __call__[[diffusers.Cosmos2TextToImagePipeline.__call__]]
```python
__call__(prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 768, width: int = 1360, num_inference_steps: int = 35, guidance_scale: float = 7.0, num_images_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_text2image.py#L417)
**المعاملات:**
prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي تُوجّه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `prompt_embeds` بدلاً من ذلك.
negative_prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي لا ينبغي أن توجه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `negative_prompt_embeds` بدلاً من ذلك. يتم تجاهله عند عدم استخدام التوجيه (أي يُتجاهل إذا لم يكن `guidance_scale` أكبر من `1`).
height (`int`، القيمة الافتراضية `768`) : ارتفاع الصورة المولّدة بالبكسل.
width (`int`، القيمة الافتراضية `1360`) : عرض الصورة المولدة بالبكسل.
num_inference_steps (`int`، القيمة الافتراضية `35`) : عدد خطوات إزالة الضوضاء. تؤدي زيادة عدد خطوات إزالة الضوضاء عادةً إلى صورة ذات جودة أعلى على حساب بطء الاستدلال.
guidance_scale (`float`، القيمة الافتراضية `7.0`) : مقياس التوجيه كما هو معرّف في [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). يُعرَّف `guidance_scale` على أنه `w` من المعادلة 2. في [Imagen Paper](https://huggingface.co/papers/2205.11487). يتم تفعيل مقياس التوجيه عن طريق تعيين `guidance_scale > 1`.
num_images_per_prompt (`int`، *اختياري*، القيمة الافتراضية 1) : عدد الصور التي سيتم توليدها لكل موجه.
generator (`torch.Generator` أو `list[torch.Generator]`، *اختياري*) : [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) لجعل التوليد حتميًا.
latents (`torch.Tensor`، *اختياري*) : كامنات ضجيج مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات لتوليد الصور. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كامنات من خلال الاستخراج باستخدام `generator` العشوائي المُقدَّم.
prompt_embeds (`torch.Tensor`، *اختياري*) : تمثيلات نصية مُولّدة مسبقًا. يمكن استخدامها لتعديل مدخلات النص بسهولة، *مثلًا* وزن الأوامر. إذا لم تُقدَّم، فسيتم توليد تمثيلات النص من معامل الإدخال `prompt`.
negative_prompt_embeds (`torch.FloatTensor`، *اختياري*) : تمثيلات نصية سالبة مُولّدة مسبقًا. بالنسبة إلى PixArt-Sigma، يجب أن يكون هذا الأمر السلبي "". إذا لم يُقدَّم، فسيتم توليد negative_prompt_embeds من معامل الإدخال `negative_prompt`.
output_type (`str`، *اختياري*، الافتراضي `"pil"`) : صيغة الصورة المولّدة. اختر بين `PIL.Image` أو `np.array`.
return_dict (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان يجب إرجاع `CosmosImagePipelineOutput` بدلاً من tuple عادي.
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`) : الحد الأقصى لعدد الرموز في الاستعلام. إذا تجاوز الاستعلام هذا الطول، فسيتم اقتطاعه. وإذا كان الاستعلام أقصر من هذا الطول، فسيتم ملؤه.
**يعيد:** `~CosmosImagePipelineOutput` أو `tuple`
إذا كان `return_dict` هو `True`، يُعاد `CosmosImagePipelineOutput`، وإلا يُعاد `tuple` حيث يكون العنصر الأول قائمة بالصور المولّدة والعنصر الثاني قائمة من قيم `bool` تشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى "غير آمن للعمل" (nsfw).
دالة الاستدعاء call لخط الأنابيب pipeline الخاص بالتوليد.
أمثلة:
```python
>>> import torch
>>> from diffusers import Cosmos2TextToImagePipeline
>>> # Available checkpoints: nvidia/Cosmos-Predict2-2B-Text2Image, nvidia/Cosmos-Predict2-14B-Text2Image
>>> model_id = "nvidia/Cosmos-Predict2-2B-Text2Image"
>>> pipe = Cosmos2TextToImagePipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> prompt = "A close-up shot captures a vibrant yellow scrubber vigorously working on a grimy plate, its bristles moving in circular motions to lift stubborn grease and food residue. The dish, once covered in remnants of a hearty meal, gradually reveals its original glossy surface. Suds form and bubble around the scrubber, creating a satisfying visual of cleanliness in progress. The sound of scrubbing fills the air, accompanied by the gentle clinking of the dish against the sink. As the scrubber continues its task, the dish transforms, gleaming under the bright kitchen lights, symbolizing the triumph of cleanliness over mess."
>>> negative_prompt = "The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality."
>>> output = pipe(
... prompt=prompt, negative_prompt=negative_prompt, generator=torch.Generator().manual_seed(1)
... ).images[0]
>>> output.save("output.png")
```
#### encode_prompt[[diffusers.Cosmos2TextToImagePipeline.encode_prompt]]
```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_images_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_text2image.py#L254)
**المعاملات:**
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_images_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 dtype
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
## Cosmos2VideoToWorldPipeline[[diffusers.Cosmos2VideoToWorldPipeline]]
#### diffusers.Cosmos2VideoToWorldPipeline[[diffusers.Cosmos2VideoToWorldPipeline]]
```python
diffusers.Cosmos2VideoToWorldPipeline(text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: CosmosTransformer3DModel, vae: AutoencoderKLWan, scheduler: FlowMatchEulerDiscreteScheduler, safety_checker: CosmosSafetyChecker = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_video2world.py#L162)
**المعاملات:**
text_encoder (`T5EncoderModel`) : مُشفِّر نص ثابت. يستخدم Cosmos [T5](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel)؛ وتحديداً النسخة [t5-11b](https://huggingface.co/google-t5/t5-11b).
tokenizer (`T5TokenizerFast`) : مُجزِّئ من الفئة [T5Tokenizer](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Tokenizer).
transformer ([CosmosTransformer3DModel](/docs/diffusers/main/ar/api/models/cosmos_transformer3d#diffusers.CosmosTransformer3DModel)) : نموذج Transformer مشروط لإزالة الضوضاء من الكامنات (latents) المُرمّزة للصور.
scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ar/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : مُجدوِل يُستخدم بالاقتران مع `transformer` لإزالة الضوضاء من كامنات الصورة المُرمَّزة.
vae ([AutoencoderKLWan](/docs/diffusers/main/ar/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan)) : نموذج الترميز التحويلي التبايني (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
خط أنابيب لتوليد العالم من الفيديو باستخدام [Cosmos Predict2](https://github.com/nvidia-cosmos/cosmos-predict2).
يرث هذا النموذج من [DiffusionPipeline](/docs/diffusers/main/ar/api/pipelines/overview#diffusers.DiffusionPipeline). راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
#### __call__[[diffusers.Cosmos2VideoToWorldPipeline.__call__]]
```python
__call__(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]] = None, video: list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]] = None, prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int = 704, width: int = 1280, num_frames: int = 93, num_inference_steps: int = 35, guidance_scale: float = 7.0, fps: int = 16, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512, sigma_conditioning: float = 0.0001)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_video2world.py#L485)
**المعاملات:**
image (`PIL.Image.Image`، `np.ndarray`، `torch.Tensor`، *اختياري*) : الصورة التي سيتم استخدامها كمدخل شرطي لتوليد الفيديو.
video (`list[PIL.Image.Image]`، `np.ndarray`، `torch.Tensor`، *اختياري*) : الفيديو الذي سيُستخدم كمدخل تكييفي لتوليد الفيديو.
prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي تُوجّه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `prompt_embeds` بدلاً من ذلك.
negative_prompt (`str` أو `list[str]`، *اختياري*) : الأمر أو الأوامر التي لا ينبغي أن توجه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `negative_prompt_embeds` بدلاً من ذلك. يتم تجاهله عند عدم استخدام التوجيه (أي يُتجاهل إذا لم يكن `guidance_scale` أكبر من `1`).
height (`int`، القيمة الافتراضية `704`) : ارتفاع الصورة المولّدة بالبكسل.
width (`int`، القيمة الافتراضية `1280`) : عرض الصورة المولدة بالبكسل.
num_frames (`int`، القيمة الافتراضية `93`) : عدد الإطارات في الفيديو المولّد.
num_inference_steps (`int`، القيمة الافتراضية `35`) : عدد خطوات إزالة الضوضاء. تؤدي زيادة عدد خطوات إزالة الضوضاء عادةً إلى صورة ذات جودة أعلى على حساب بطء الاستدلال.
guidance_scale (`float`، القيمة الافتراضية `7.0`) : مقياس التوجيه كما هو معرّف في [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). يُعرَّف `guidance_scale` على أنه `w` من المعادلة 2. في [Imagen Paper](https://huggingface.co/papers/2205.11487). يتم تفعيل مقياس التوجيه عن طريق تعيين `guidance_scale > 1`.
fps (`int`، القيمة الافتراضية `16`) : عدد الإطارات في الثانية للفيديو المولّد.
num_videos_per_prompt (`int`، *اختياري*، القيمة الافتراضية 1) : عدد الصور التي سيتم توليدها لكل موجه.
generator (`torch.Generator` أو `list[torch.Generator]`، *اختياري*) : [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) لجعل التوليد حتميًا.
latents (`torch.Tensor`، *اختياري*) : كامنات ضجيج مُولّدة مسبقًا، مُستخرجة من توزيع غاوسي، تُستخدم كمدخلات لتوليد الصور. يمكن استخدامها لتعديل نفس التوليد باستخدام أوامر مختلفة. إذا لم تُقدَّم، يتم توليد كامنات من خلال الاستخراج باستخدام `generator` العشوائي المُقدَّم.
prompt_embeds (`torch.Tensor`، *اختياري*) : تمثيلات نصية مُولّدة مسبقًا. يمكن استخدامها لتعديل مدخلات النص بسهولة، *مثلًا* وزن الأوامر. إذا لم تُقدَّم، فسيتم توليد تمثيلات النص من معامل الإدخال `prompt`.
negative_prompt_embeds (`torch.FloatTensor`، *اختياري*) : تمثيلات نصية سالبة مُولّدة مسبقًا. بالنسبة إلى PixArt-Sigma، يجب أن يكون هذا الأمر السلبي "". إذا لم يُقدَّم، فسيتم توليد negative_prompt_embeds من معامل الإدخال `negative_prompt`.
output_type (`str`، *اختياري*، الافتراضي `"pil"`) : صيغة الصورة المولّدة. اختر بين `PIL.Image` أو `np.array`.
return_dict (`bool`، *اختياري*، القيمة الافتراضية `True`) : ما إذا كان يجب إرجاع `CosmosPipelineOutput` بدلاً من tuple عادي.
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`) : الحد الأقصى لعدد الرموز في الاستعلام. إذا تجاوز الاستعلام هذا الطول، فسيتم اقتطاعه. وإذا كان الاستعلام أقصر من هذا الطول، فسيتم ملؤه.
sigma_conditioning (`float`، القيمة الافتراضية `0.0001`) : قيمة سيجما المستخدمة لتقييد الكامنات الشرطية. من الأفضل عدم تغييرها أو ضبطها على قيمة صغيرة قريبة من الصفر.
**يعيد:** `~CosmosPipelineOutput` أو `tuple`
إذا كان `return_dict` هو `True`، يُعاد `CosmosPipelineOutput`، وإلا يُعاد `tuple` حيث يكون العنصر الأول قائمة بالصور المولّدة والعنصر الثاني قائمة من قيم `bool` تشير إلى ما إذا كانت الصورة المولّدة المقابلة تحتوي على محتوى "غير آمن للعمل" (nsfw).
دالة الاستدعاء call لخط الأنابيب pipeline الخاص بالتوليد.
أمثلة:
```python
>>> import torch
>>> from diffusers import Cosmos2VideoToWorldPipeline
>>> from diffusers.utils import export_to_video, load_image
>>> # Available checkpoints: nvidia/Cosmos-Predict2-2B-Video2World, nvidia/Cosmos-Predict2-14B-Video2World
>>> model_id = "nvidia/Cosmos-Predict2-2B-Video2World"
>>> pipe = Cosmos2VideoToWorldPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> prompt = "A close-up shot captures a vibrant yellow scrubber vigorously working on a grimy plate, its bristles moving in circular motions to lift stubborn grease and food residue. The dish, once covered in remnants of a hearty meal, gradually reveals its original glossy surface. Suds form and bubble around the scrubber, creating a satisfying visual of cleanliness in progress. The sound of scrubbing fills the air, accompanied by the gentle clinking of the dish against the sink. As the scrubber continues its task, the dish transforms, gleaming under the bright kitchen lights, symbolizing the triumph of cleanliness over mess."
>>> negative_prompt = "The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality."
>>> image = load_image(
... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/yellow-scrubber.png"
... )
>>> video = pipe(
... image=image, prompt=prompt, negative_prompt=negative_prompt, generator=torch.Generator().manual_seed(1)
... ).frames[0]
>>> export_to_video(video, "output.mp4", fps=16)
```
#### encode_prompt[[diffusers.Cosmos2VideoToWorldPipeline.encode_prompt]]
```python
encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_video2world.py#L273)
**المعاملات:**
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 dtype
يقوم بتشفير الموجه إلى حالات مخفية لمشفّر النص.
## CosmosPipelineOutput[[diffusers.pipelines.cosmos.pipeline_output.CosmosPipelineOutput]]
#### diffusers.pipelines.cosmos.pipeline_output.CosmosPipelineOutput[[diffusers.pipelines.cosmos.pipeline_output.CosmosPipelineOutput]]
```python
diffusers.pipelines.cosmos.pipeline_output.CosmosPipelineOutput(frames: Tensor)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_output.py#L14)
**المعاملات:**
frames (`torch.Tensor` أو `np.ndarray` أو list[list[PIL.Image.Image]]) : قائمة من مخرجات الفيديو - يمكن أن تكون قائمة متداخلة بطول `batch_size,` حيث تحتوي كل قائمة فرعية على تسلسلات من صور PIL منزوعة الضوضاء بطول `num_frames.` كما يمكن أن تكون مصفوفة NumPy أو متجه Torch بشكل `(batch_size, num_frames, channels, height, width)`.
فئة الإخراج لخطوط أنابيب Cosmos من أي شيء إلى العالم/الفيديو.
## CosmosImagePipelineOutput[[diffusers.pipelines.cosmos.pipeline_output.CosmosImagePipelineOutput]]
#### diffusers.pipelines.cosmos.pipeline_output.CosmosImagePipelineOutput[[diffusers.pipelines.cosmos.pipeline_output.CosmosImagePipelineOutput]]
```python
diffusers.pipelines.cosmos.pipeline_output.CosmosImagePipelineOutput(images: list[PIL.Image.Image] | numpy.ndarray)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_output.py#L29)
**المعاملات:**
images (`list[PIL.Image.Image]` أو `np.ndarray`) : قائمة من صور PIL منزوعة الضوضاء بطول `batch_size` أو مصفوفة numpy بأبعاد `(batch_size, height, width, num_channels)`. تمثل صور PIL أو مصفوفة numpy صورًا منزوعة الضوضاء من خط أنابيب الانتشار.
فئة الإخراج لخطوط أنابيب Cosmos من أي شيء إلى صورة.
#
# مرخّص بموجب ترخيص Apache الإصدار 2.0 (المسمى "الترخيص")
# لا يجوز لك استخدام هذا الملف إلا وفقاً لشروط الترخيص.
# يمكنك الحصول على نسخة من الترخيص في
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ما لم يقتضِ ذلك القانون المعمول به أو ما اتُّفق عليه كتابياً، البرمجيات
# تُوزَّع بموجب الرخصة على أساس "كما هي"،
# بلا أي ضمانات أو شروط من أي نوع، سواء صريحة أو ضمنية.
# راجع الترخيص لمعرفة اللغة المحددة التي تحكم الصلاحيات و
# قيود بموجب الترخيص. -->
# Cosmos
[منصة نموذج الأساس الكوني Cosmos للذكاء الاصطناعي الفيزيائي](https://huggingface.co/papers/2501.03575) من NVIDIA.
*يتطلب الذكاء الاصطناعي المادي أن يُدرَّب رقميًا أولًا. فهو يحتاج إلى توأم رقمي لنفسه، وهو نموذج السياسة، وتوأم رقمي للعالم، وهو نموذج العالم. في هذه الورقة، نقدم منصة نماذج الأساس للعالم (Cosmos World Foundation Model Platform) لمساعدة المطورين على بناء نماذج عالم مخصصة لإعدادات الذكاء الاصطناعي المادي الخاصة بهم. نضع نموذج الأساس للعالم كنموذج عالم ذي استخدام عام يمكن ضبطه بدقة ليصبح نموذج عالم مخصصًا للتطبيقات اللاحقة. تغطي منصتنا خط أنابيب لفرز الفيديو، ونماذج أساس للعالم مُدرَّبة مسبقًا، وأمثلة على التدريب اللاحق لنماذج الأساس للعالم المُدرَّبة مسبقًا، ومُرمِّزات رموز الفيديو. وللمساعدة في حل أكثر مشاكل مجتمعنا إلحاحًا، نجعل منصتنا مفتوحة المصدر ونماذجنا مفتوحة الأوزان مع تراخيص سائبة متاحة عبر https://github.com/NVIDIA/Cosmos.*
> [!TIP]
> تأكد من الاطلاع على [دليل المجدولين](../../using-diffusers/schedulers) لمعرفة كيفية استكشاف التوازن بين سرعة المجدول وجودة النتائج، واطّلع على قسم [إعادة استخدام المكونات عبر خطوط الأنابيب](../../using-diffusers/loading#reusing-models-in-multiple-pipelines) لمعرفة كيفية تحميل نفس المكونات بكفاءة في خطوط أنابيب متعددة.
## الاستخدام الأساسي
```python
import torch
from diffusers import Cosmos2_5_PredictBasePipeline
from diffusers.utils import export_to_video
model_id = "nvidia/Cosmos-Predict2.5-2B"
pipe = Cosmos2_5_PredictBasePipeline.from_pretrained(
model_id, revision="diffusers/base/post-trained", dtype=torch.bfloat16
)
pipe.to("cuda") # or "mps", "xpu", "cpu"
prompt = "As the red light shifts to green, the red bus at the intersection begins to move forward, its headlights cutting through the falling snow. The snowy tire tracks deepen as the vehicle inches ahead, casting fresh lines onto the slushy road. Around it, streetlights glow warmer, illuminating the drifting flakes and wet reflections on the asphalt. Other cars behind start to edge forward, their beams joining the scene. The stillness of the urban street transitions into motion as the quiet snowfall is punctuated by the slow advance of traffic through the frosty city corridor."
negative_prompt = "The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality."
output = pipe(
image=None,
video=None,
prompt=prompt,
negative_prompt=negative_prompt,
num_frames=93,
generator=torch.Generator().manual_seed(1),
).frames[0]
export_to_video(output, "text2world.mp4", fps=16)
```
## Cosmos2_5_TransferPipeline[[diffusers.Cosmos2_5_TransferPipeline]]
#### diffusers.Cosmos2_5_TransferPipeline[[diffusers.Cosmos2_5_TransferPipeline]]
```python
diffusers.Cosmos2_5_TransferPipeline(text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: AutoTokenizer, transformer: CosmosTransformer3DModel, vae: AutoencoderKLWan, scheduler: UniPCMultistepScheduler, controlnet: CosmosControlNetModel, safety_checker: typing.Optional[diffusers.pipelines.cosmos.pipeline_cosmos2_5_transfer.CosmosSafetyChecker] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_transfer.py#L152)
**المعاملات:**
text_encoder (`Qwen2_5_VLForConditionalGeneration`) : مُشفِّر نص ثابت. يستخدم Cosmos Transfer2.5 مُشفِّر [Qwen2.5 VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct).
tokenizer (`AutoTokenizer`) : مُجزِّئ (Tokenizer) مرتبط بمُشفِّر (encoder) نموذج Qwen2.5 VL.
transformer ([CosmosTransformer3DModel](/docs/diffusers/main/ar/api/models/cosmos_transformer3d#diffusers.CosmosTransformer3DModel)) : نموذج Transformer مشروط لإزالة الضوضاء من الكامنات (latents) المُرمّزة للصور.
scheduler ([UniPCMultistepScheduler](/docs/diffusers/main/ar/api/schedulers/unipc#diffusers.UniPCMultistepScheduler)) : مُجدول يُستخدم بالاقتران مع `transformer` لإزالة الضوضاء من كامنات الصورة المُرمّزة.
vae ([AutoencoderKLWan](/docs/diffusers/main/ar/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan)) : نموذج الترميز التحويلي التبايني (VAE) لتشفير وفك تشفير مقاطع الفيديو إلى تمثيلات كامنة ومنها.
controlnet (`CosmosControlNetModel`) : ControlNet المستخدم لتكييف التوليد على مدخلات التحكم.
خط أنابيب لنموذج Cosmos Transfer2.5، يدعم الاستدلال التلقائي التتابعي.
يرث هذا النموذج من [DiffusionPipeline](/docs/diffusers/main/ar/api/pipelines/overview#diffusers.DiffusionPipeline). راجع توثيق الفئة الأصلية لمعرفة الطرق العامة المُنفَّذة لجميع خطوط الأنابيب (التنزيل، الحفظ، التشغيل على جهاز معين، إلخ).
#### __call__[[diffusers.Cosmos2_5_TransferPipeline.__call__]]
```python
__call__(controls: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], typing.List[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]]], controls_conditioning_scale: typing.Union[float, typing.List[float]] = 1.0, prompt: typing.Union[str, typing.List[str], NoneType] = None, negative_prompt: typing.Union[str, typing.List[str]] = 'The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality.', height: int = 704, width: typing.Optional[int] = None, num_frames: typing.Optional[int] = None, num_frames_per_chunk: int = 93, num_inference_steps: int = 36, guidance_scale: float = 3.0, num_videos_per_prompt: int = 1, generator: typing.Union[torch.Generator, typing.List[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: typing.Optional[str] = 'pil', return_dict: bool = True, callback_on_step_end: typing.Union[typing.Callable[[int, int, typing.Dict], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: typing.List[str] = ['latents'], max_sequence_length: int = 512, conditional_frame_timestep: float = 0.1, num_ar_conditional_frames: typing.Optional[int] = 1, num_ar_latent_conditional_frames: typing.Optional[int] = None)
```
[المصدر](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_transfer.py#L569)
**المعاملات:**
controls (`PipelineImageInput`، `List[PipelineImageInput]`) : صورة أو فيديو إدخال للتحكم تُستخدم بواسطة ControlNet.
controls_conditioning_scale (`float` أو `List[float]`، *اختياري*، القيمة الافتراضية `1.0`) : عامل/عوامل المقياس لمخرجات ControlNet. يتم بث قيمة float واحدة إلى جميع كتل التحكم.
prompt (`str` أو `List[str]`، *اختياري*) : الأمر أو الأوامر التي تُوجّه عملية التوليد. مطلوب ما لم يُقدَّم `prompt_embeds`.
negative_prompt (`str` أو `List[str]`، *اختياري*) : الأمر أو الأوامر التي لا ينبغي أن توجّه توليد الصورة. إذا لم يُعرَّف، يجب تمرير `negative_prompt_embeds` بدلاً من ذلك. يُتجاهل عند عدم استخدام التوجيه (أي يُتجاهل إذا لم يكن `guidance_scale` أكبر من `1`).
height (`int`، القيمة الافتراضية `704`) : ارتفاع الصورة المولّدة بالبكسل.
width (`int`, *اختياري*) : عرض الصورة المولدة بالبكسل. إذا لم يُقدَّم، فسيتم تحديده بناءً على نسبة أبعاد الإدخال والارتفاع المقدم.
num_frames (`int`, *اختياري*) : عدد الإطارات المُخرَجة. القيمة الافتراضية هي `None` لإخراج عدد إطارات مطابق لعدد إطارات الإدخال `controls`.
Xet Storage Details
- Size:
- 99.4 kB
- Xet hash:
- 6a5cedfdc6012f6ecc0a8156b614eb83bf5417c18487046c137ad4669175b00e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.