Cosmos¶
Cosmos World Foundation Models are specialized to generate videos and world states that accurately adhere to the laws of physics. Using diffusion-based technology, these models create dynamic, high-quality videos from various inputs like text, images, or videos. RBLN NPUs can accelerate Cosmos pipelines using Optimum RBLN.
Supported Pipelines¶
Optimum RBLN supports several Cosmos pipelines:
- Text-to-Video: Generate high-quality videos from text prompts.
- Video-to-Video: Generate high-quality videos from input videos and text prompts.
Important: Cosmos Safety Guardrails¶
NVIDIA Open Model License
According to NVIDIA Open Model License policy, your rights will automatically terminate if you bypass, disable, weaken, or otherwise circumvent the Cosmos safety guardrails.
Usage Example (Text-to-Video)¶
Usage Example (Video-to-Video)¶
API Reference¶
Classes¶
RBLNCosmosTextToWorldPipeline
¶
Bases: RBLNDiffusionMixin
, CosmosTextToWorldPipeline
RBLN-accelerated implementation of Cosmos Text to World pipeline for text-to-video generation.
This pipeline compiles Cosmos Text to World models to run efficiently on RBLN NPUs, enabling high-performance inference for generating videos with distinctive artistic style and enhanced visual quality.
Functions¶
from_pretrained(model_id, *, export=False, safety_checker=None, rbln_config={}, **kwargs)
classmethod
¶
Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.
It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_id
|
`str`
|
The model ID or path to the pretrained model to load. Can be either:
|
required |
export
|
bool
|
If True, takes a PyTorch model from |
False
|
safety_checker
|
Optional[RBLNCosmosSafetyChecker]
|
Optional custom safety checker to use instead of the default one. Only used when |
None
|
rbln_config
|
Dict[str, Any]
|
Configuration options for RBLN compilation. Can include settings for specific submodules
such as |
{}
|
kwargs
|
Any
|
Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used. |
{}
|
Functions¶
Classes¶
RBLNCosmosVideoToWorldPipeline
¶
Bases: RBLNDiffusionMixin
, CosmosVideoToWorldPipeline
RBLN-accelerated implementation of Cosmos Video to World pipeline for video-to-video generation.
This pipeline compiles Cosmos Video to World models to run efficiently on RBLN NPUs, enabling high-performance inference for generating videos with distinctive artistic style and enhanced visual quality.
Functions¶
from_pretrained(model_id, *, export=False, safety_checker=None, rbln_config={}, **kwargs)
classmethod
¶
Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.
It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_id
|
`str`
|
The model ID or path to the pretrained model to load. Can be either:
|
required |
export
|
bool
|
If True, takes a PyTorch model from |
False
|
safety_checker
|
Optional[RBLNCosmosSafetyChecker]
|
Optional custom safety checker to use instead of the default one. Only used when |
None
|
rbln_config
|
Dict[str, Any]
|
Configuration options for RBLN compilation. Can include settings for specific submodules
such as |
{}
|
kwargs
|
Any
|
Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used. |
{}
|
Functions¶
Classes¶
RBLNCosmosPipelineBaseConfig
¶
Bases: RBLNModelConfig
Functions¶
__init__(text_encoder=None, transformer=None, vae=None, safety_checker=None, *, batch_size=None, height=None, width=None, num_frames=None, fps=None, max_seq_len=None, **kwargs)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_encoder
|
Optional[RBLNT5EncoderModelConfig]
|
Configuration for the text encoder component. Initialized as RBLNT5EncoderModelConfig if not provided. |
None
|
transformer
|
Optional[RBLNCosmosTransformer3DModelConfig]
|
Configuration for the Transformer model component. Initialized as RBLNCosmosTransformer3DModelConfig if not provided. |
None
|
vae
|
Optional[RBLNAutoencoderKLCosmosConfig]
|
Configuration for the VAE model component. Initialized as RBLNAutoencoderKLCosmosConfig if not provided. |
None
|
safety_checker
|
Optional[RBLNCosmosSafetyCheckerConfig]
|
Configuration for the safety checker component. Initialized as RBLNCosmosSafetyCheckerConfig if not provided. |
None
|
batch_size
|
Optional[int]
|
Batch size for inference, applied to all submodules. |
None
|
height
|
Optional[int]
|
Height of the generated videos. |
None
|
width
|
Optional[int]
|
Width of the generated videos. |
None
|
num_frames
|
Optional[int]
|
The number of frames in the generated video. |
None
|
fps
|
Optional[int]
|
The frames per second of the generated video. |
None
|
max_seq_len
|
Optional[int]
|
Maximum sequence length supported by the model. |
None
|
kwargs
|
Any
|
Additional arguments passed to the parent RBLNModelConfig. |
{}
|
load(path, **kwargs)
classmethod
¶
Load a RBLNModelConfig from a path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to the RBLNModelConfig file or directory containing the config file. |
required |
kwargs
|
Any
|
Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
RBLNModelConfig |
RBLNModelConfig
|
The loaded configuration instance. |
Note
This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.
RBLNCosmosTextToWorldPipelineConfig
¶
Bases: RBLNCosmosPipelineBaseConfig
Config for Cosmos Text2World Pipeline
Functions¶
__init__(text_encoder=None, transformer=None, vae=None, safety_checker=None, *, batch_size=None, height=None, width=None, num_frames=None, fps=None, max_seq_len=None, **kwargs)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_encoder
|
Optional[RBLNT5EncoderModelConfig]
|
Configuration for the text encoder component. Initialized as RBLNT5EncoderModelConfig if not provided. |
None
|
transformer
|
Optional[RBLNCosmosTransformer3DModelConfig]
|
Configuration for the Transformer model component. Initialized as RBLNCosmosTransformer3DModelConfig if not provided. |
None
|
vae
|
Optional[RBLNAutoencoderKLCosmosConfig]
|
Configuration for the VAE model component. Initialized as RBLNAutoencoderKLCosmosConfig if not provided. |
None
|
safety_checker
|
Optional[RBLNCosmosSafetyCheckerConfig]
|
Configuration for the safety checker component. Initialized as RBLNCosmosSafetyCheckerConfig if not provided. |
None
|
batch_size
|
Optional[int]
|
Batch size for inference, applied to all submodules. |
None
|
height
|
Optional[int]
|
Height of the generated videos. |
None
|
width
|
Optional[int]
|
Width of the generated videos. |
None
|
num_frames
|
Optional[int]
|
The number of frames in the generated video. |
None
|
fps
|
Optional[int]
|
The frames per second of the generated video. |
None
|
max_seq_len
|
Optional[int]
|
Maximum sequence length supported by the model. |
None
|
kwargs
|
Any
|
Additional arguments passed to the parent RBLNModelConfig. |
{}
|
load(path, **kwargs)
classmethod
¶
Load a RBLNModelConfig from a path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to the RBLNModelConfig file or directory containing the config file. |
required |
kwargs
|
Any
|
Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
RBLNModelConfig |
RBLNModelConfig
|
The loaded configuration instance. |
Note
This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.
RBLNCosmosVideoToWorldPipelineConfig
¶
Bases: RBLNCosmosPipelineBaseConfig
Config for Cosmos Video2World Pipeline
Functions¶
__init__(text_encoder=None, transformer=None, vae=None, safety_checker=None, *, batch_size=None, height=None, width=None, num_frames=None, fps=None, max_seq_len=None, **kwargs)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_encoder
|
Optional[RBLNT5EncoderModelConfig]
|
Configuration for the text encoder component. Initialized as RBLNT5EncoderModelConfig if not provided. |
None
|
transformer
|
Optional[RBLNCosmosTransformer3DModelConfig]
|
Configuration for the Transformer model component. Initialized as RBLNCosmosTransformer3DModelConfig if not provided. |
None
|
vae
|
Optional[RBLNAutoencoderKLCosmosConfig]
|
Configuration for the VAE model component. Initialized as RBLNAutoencoderKLCosmosConfig if not provided. |
None
|
safety_checker
|
Optional[RBLNCosmosSafetyCheckerConfig]
|
Configuration for the safety checker component. Initialized as RBLNCosmosSafetyCheckerConfig if not provided. |
None
|
batch_size
|
Optional[int]
|
Batch size for inference, applied to all submodules. |
None
|
height
|
Optional[int]
|
Height of the generated videos. |
None
|
width
|
Optional[int]
|
Width of the generated videos. |
None
|
num_frames
|
Optional[int]
|
The number of frames in the generated video. |
None
|
fps
|
Optional[int]
|
The frames per second of the generated video. |
None
|
max_seq_len
|
Optional[int]
|
Maximum sequence length supported by the model. |
None
|
kwargs
|
Any
|
Additional arguments passed to the parent RBLNModelConfig. |
{}
|
load(path, **kwargs)
classmethod
¶
Load a RBLNModelConfig from a path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to the RBLNModelConfig file or directory containing the config file. |
required |
kwargs
|
Any
|
Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
RBLNModelConfig |
RBLNModelConfig
|
The loaded configuration instance. |
Note
This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.