HuggingFace镜像/Cosmos3-Nano
模型介绍文件和版本分析
下载使用量0

Cosmos 3:面向物理智能的全模态世界模型

模型集合 | 代码 | 白皮书 | 网站

NVIDIA Cosmos™ 是一个世界基础模型平台,旨在通过使机器能够在机器人技术、自动驾驶和智能空间环境(包括工业和工厂规模的应用)中理解、模拟和与物理世界交互,从而加速物理智能(Physical AI)的发展。

模型概述:Cosmos3-Nano

描述

Cosmos3 是一系列全模态世界模型的集合,能够从文本、图像、视频和动作轨迹输入的组合中生成动态、高质量的视频、图像、音频和动作指令。它作为广泛物理智能应用和研究的基础构建块,涵盖世界理解、世界生成、模拟和具身策略学习等领域。

该模型已准备好用于商业和非商业用途。

模型开发者: NVIDIA

模型版本

  • Cosmos3-Nano:

    • 给定包括文本、图像、视频、音频和动作轨迹在内的多模态输入,生成连贯的文本、图像、视频、音频和动作输出,用于多模态理解、世界模拟、未来预测、动作推理和物理智能应用。
  • Cosmos3-Super:

    • 给定包括文本、图像、视频、音频和动作轨迹在内的多模态输入,生成连贯的文本、图像、视频、音频和动作输出,用于多模态理解、世界模拟、未来预测、动作推理和物理智能应用。
  • Cosmos3-Nano-Policy-DROID:

    • 给定语言指令和来自 DROID 机器人平台的视觉观察,生成用于操纵和控制任务的机器人动作轨迹。
  • Cosmos3-Super-Image2Video:

    • 给定一个输入图像和文本指令,生成与所提供视觉内容一致的时间连贯视频序列。
  • Cosmos3-Super-Text2Image:

    • 给定文本输入,生成与所提供描述一致的高保真图像。

许可协议

本模型基于 OpenMDW1.1 许可协议发布。

部署地域

全球

应用场景

物理人工智能:涵盖机器人技术、自动驾驶汽车(AV)以及智能空间环境,包括工业和工厂规模的应用。

发布日期

Hugging Face:2026年5月31日,通过 https://huggingface.co/collections/nvidia/cosmos3 GitHub:2026年5月31日,通过 https://github.com/nvidia/cosmos

模型架构

架构类型: Transformer

网络架构: 混合Transformer(Mixture-of-Transformers,MoT)

Cosmos3 是一个全模态基础模型,构建于混合Transformer(MoT)架构之上,包含两个互补的Transformer塔:一个用于离散 token 生成的自回归Transformer,以及一个用于连续多模态生成的扩散Transformer。在推理过程中,文本通过标准的下一个 token 自回归解码生成,而非文本模态(如图像、视频、音频和动作)则通过迭代去噪合成。这种统一的架构使 Cosmos3 能够在单一框架内对异构模态进行建模,同时保留每种模态最适合的生成机制。

本模型基于以下技术开发: Cosmos Framework

可训练模型参数数量:

  • Cosmos3-Nano:160亿
  • Cosmos3-Super:640亿
  • Cosmos3-Nano-Policy-DROID:160亿
  • Cosmos3-Super-Image2Video:640亿
  • Cosmos3-Super-Text2Image:640亿

输入/输出规格

  • 生成器输入
    • 输入类型: 文本、图像、视频(带音频或不带音频)、动作轨迹
    • 输入格式:
      • 文本:字符串
      • 图像:jpg、png、jpeg、webp
      • 视频(带或不带音频):mp4
      • 动作:json(一维列表)
    • 输入参数:
      • 文本:一维(1D)
      • 图像:二维(2D)
      • 视频:三维(3D)
      • 音频:一维(1D)
      • 动作轨迹:一维(1D)
    • 与输入相关的其他属性:
      • 对于视频输入,我们接受多种分辨率,包括720p、480p和256p。
      • 当使用音频混合到视频MP4文件中的输入视频时,音频应具有2个声道(立体声)和48 kHz的采样率。
      • 图像和视频输入为RGB颜色(每通道8位,sRGB色彩空间);不支持灰度输入。
      • 动作输入是每帧的机器人/智能体状态或控制值序列(例如,关节位置、夹爪状态、相机姿态)。完整输入是一个形状为(T, D)的二维数组,其中 T 是帧数,D 是下文列出的特定实体的维度。
      • 输入动作仅支持兼容的实体,包括通用相机运动(9D)、自动驾驶汽车(9D)、第一人称运动(57D)、带RobotiQ夹爪的单个Franka Panda机械臂(10D)、带RobotiQ夹爪的双Franka Panda机械臂(20D)、Agibot(29D)、UR(10D)、Google机器人(10D)、WidowX 250(10D)、UMI(9D)。
    • 输入大小和长度限制:
      • 文本: 4096个token
      • 图像: 256p、480p和720p分辨率,且具有以下宽高比之一(16:9、4:3、1:1、3:4、9:16)
      • 视频: 256p、480p和720p分辨率,且具有以下宽高比之一(16:9、4:3、1:1、3:4、9:16)。最大帧数 = 5。
      • 音频: 最长0.5秒
      • 动作: 16 – 400个视频帧
  • 生成器输出
    • 输出类型: 图像、视频、音频、动作、文本
    • 输出格式:
      • 图像:JPG
      • 视频:MP4
      • 音频:高级音频编码(AAC)流(混合在MP4中)
      • 动作:一维列表(.json)
      • 文本:字符串
    • 输出参数:
      • 图像:二维(2D)
      • 视频:三维(3D)
      • 音频:一维(1D)
      • 动作:一维(1D)
      • 文本:一维(1D)
    • 与输出相关的其他属性:
      • 生成的视频是MP4文件,其分辨率、帧率和时长由输入指定。生成的音频以AAC格式编码,混合到视频MP4文件中,具有2个声道(立体声)和48 kHz的采样率。
      • 视频生成支持5到400帧的时长,默认生成时长为189帧。
      • 生成的动作仅支持兼容的实体,包括通用相机运动(9D)、自动驾驶汽车(9D)、第一人称运动(57D)、带RobotiQ夹爪的单个Franka Panda机械臂(10D)、带RobotiQ夹爪的双Franka Panda机械臂(20D)、Agibot(29D)、UR(10D)、Google机器人(10D)、WidowX 250(10D)、UMI(9D)。
      • 音频:48 kHz立体声AAC流混合到视频mp4中
      • 视频:mp4格式,帧率与输入指定的一致
      • 图像:JPEG格式
  • 推理器输入
    • 输入类型: 文本、文本+图像、文本+视频
    • 输入格式:
      • 文本:字符串
      • 图像:jpg、png、jpeg、webp
      • 视频:mp4
    • 输入参数:
      • 文本:一维(1D)
      • 图像:二维(2D)
      • 视频:三维(3D)
    • 与输入相关的其他属性:
      • 建议视频输入的帧率为4 fps。
      • 支持长上下文输入,最多可达256K token。
    • 输入大小和长度限制:
      • 文本: 最多256K token(上下文窗口)。
      • 图像: 标准输入图像格式;以文件或URL形式传入。
      • 视频: mp4格式,建议帧率为4 fps。
  • 推理器输出
    • 输出类型: 文本
    • 输出格式:
      • 文本:字符串
    • 输出参数:
      • 文本:一维(1D)
    • 与输出相关的其他属性:
      • 推理输出建议默认 max_tokens=4096+;可请求更长的输出。
      • 推理输出可能包括结构化的思维链、用于视觉任务的2D/3D点定位以及边界框坐标。

视频内容将输入文本描述可视化为简短的动画场景,在指定的时间限制内捕捉关键元素。

我们的AI模型设计和/或优化用于在NVIDIA GPU加速系统上运行。通过利用NVIDIA的硬件(例如GPU核心)和软件框架(例如CUDA库),与仅使用CPU的解决方案相比,该模型实现了更快的训练和推理时间。

软件集成

运行时引擎:

  • PyTorch
  • vLLM-Omni
  • Hugging Face Diffusers

支持的硬件微架构兼容性:

  • NVIDIA Ampere
  • NVIDIA Blackwell
  • NVIDIA Hopper

操作系统:

  • Linux

注意: 仅测试了 BF16 精度。其他精度(如 FP4、FP8 和 FP16)未获得官方支持。

将基础模型和微调模型集成到 AI 系统中,需要使用特定用例的数据进行额外测试,以确保安全有效的部署。遵循 V 模型方法,在单元和系统层面进行迭代测试和验证至关重要,这有助于在部署前降低风险、满足技术和功能要求,并确保符合安全和道德标准。

训练、测试和评估数据集

数据集概述

  • 总大小: 13 亿个数据点
  • 数据集总数: 393 个数据集条目
  • 数据集划分: 训练集 [100%],测试集 [不适用 — 评估基准单独使用],验证集 [不适用 — 评估基准单独使用]
  • 训练数据收集时间段: 2024–2026
  • 测试数据收集时间段: 不适用(标准公共基准)
  • 验证数据收集时间段: 不适用(标准公共基准)

来自内部和外部来源的原始数据通过多个阶段的整理、筛选和质量审查,转换为可用于训练的数据。数据采集涵盖多种多模态来源——机器人技术、自动驾驶、工业环境、室内外场景、不同光照和天气条件、摄像机视角、物体类别以及人类活动——以扩大在物理 AI 操作环境中的覆盖范围。自动化筛选管道会移除损坏、重复、低质量和受限制的内容。在预处理阶段,应用元数据分析、启发式规则和模型辅助分类器来标记异常分布和低多样性子集。人工审核对选定数据集、基准构建和目标质量分析的自动化筛选起到补充作用。数据集在多种模态和任务类别之间保持平衡——视觉推理、文本到图像、文本到视频、图像到视频、音频生成、视频转换、动作条件生成和动作命令生成——以减少狭窄领域的过度代表性。合成和基于模拟的增强补充了对罕见物理交互和边缘情况场景的覆盖。在整个语料库中应用去重和来源跟踪。最终处理后的数据在开始训练前,通过特定于模态的预处理器转换为模型就绪的标记化或编码表示。

训练数据集经过多层自动化和人工保护措施处理,旨在减少各类有害或违反政策内容的存在,这些类别包括武器及与武器相关的指导内容、犯罪策划、儿童性虐待材料 (CSAM)、非自愿私密图像 (NCII)、涉及未成年人的性内容、骚扰、仇恨言论、亵渎、威胁和煽动暴力、自残或自杀相关内容以及血腥暴力。在将数据纳入训练语料库之前,会对数据源进行许可兼容性、来源以及与内部数据治理和安全政策的一致性审查。自动化筛选管道结合了多种检测策略:针对已知 CSAM 和 NCII 参考数据库的哈希匹配;为显式性内容、仇恨言论、暴力、武器图像和其他受限制类别训练的基于分类器的审核模型;针对文本数据中犯罪策划、威胁和自残短语的关键字和正则表达式筛选;针对源级别风险信号的元数据和来源启发式方法;以及用于发现超出预期分布样本的基于嵌入的异常检测。人工审核和目标审计对选定数据集、基准构建和安全敏感评估的自动化筛选起到补充作用。对于多模态物理 AI 数据(机器人技术、自动驾驶、工业场景),额外的筛选针对无效的动作轨迹、物理上不合理的交互以及不安全的控制序列。合成和模拟生成的数据在纳入前经过内部验证。训练后应用基准评估和红队测试,以发现世界生成、推理、音频和动作任务中剩余的安全漏洞。没有任何大规模数据筛选过程能够保证完全删除所有有害内容;残余风险可能仍然存在,特别是在罕见的边缘情况或开放世界部署环境中。发布后将继续进行持续监控和数据集审查。

数据模态和训练数据大小

模态推理数据样本数生成数据样本数
文本2200 万不适用
图像1900 万7.67 亿
视频100 万3.48 亿
音频不适用1.39 亿
动作不适用800 万

按数据集划分的数据收集方法

  • 混合:自动/传感器、合成、自动化

按数据集划分的标注方法

  • 混合:人工、自动化

特性: 训练、测试和评估数据集由多样化的多模态视频、图像、音频、动作、合成和传感器条件数据组成,这些数据来源于 NVIDIA 拥有的数据以及公开可用的、商业许可的数据集。这些数据集经过精心整理,排除了已知的受限制内容,并支持构建一个 Omni 模型,该模型学习在世界推理和生成任务中对动态物理环境进行生成和推理。

公开数据集

数据集                                                            样本量          
OpenImage120万
Coyo700M1亿
YouTube Video3.4亿
UMI450万

私有数据集

数据集                                                            样本量          
Egocentric700万
Nexar60万
AgiBot20万
HOI30万

合成数据集

数据集样本量
使用HiDream-I1生成的合成图像1500万
使用Qwen-Image-2512生成的合成图像1400万
使用Qwen3-VL生成的合成文本描述11.15亿

评估数据集

各数据集的数据收集方法

  • 混合:自动/传感器、合成、自动化

各数据集的标注方法

  • 混合:人工、自动化

特性: 训练、测试和评估数据集包含多样化的多模态视频、图像、音频、动作、合成数据以及传感器条件数据,这些数据来源于NVIDIA所有的数据以及公开可用的、商业许可的数据集。这些数据集经过精心筛选,排除了已知的受限内容,旨在支持构建一个Omni模型,使其能够学习在世界推理和生成任务中对动态物理环境进行生成和推理。

基准测试

有关基础模型的详细评估,请参见我们的技术论文。

总体情况

总体基准测试结果

推理基准测试

推理基准测试

生成基准测试

视觉-音频生成

视觉与音频生成基准测试

动作

动作基准测试 — 正向和逆向动力学

使用方法

  • 详情请参见 Cosmos。

提示词上采样

为获得最佳质量,文本提示词应上采样为特定的 JSON 结构。相关说明和代码可在 此处 找到。

例如,使用 Opus-4.6 进行文本到视频的上采样:

git clone https://github.com/NVIDIA/cosmos-framework.git packages/cosmos-framework
pip install -e packages/cosmos-framework

export PROMPT_UPSAMPLER_ENDPOINT_URL="https://api.anthropic.com/v1/"
export PROMPT_UPSAMPLER_MODEL_NAME="claude-opus-4-6"
export PROMPT_UPSAMPLER_API_TOKEN="<you_token>"

python -m cosmos_framework.inference.prompt_upsampling \
    --input assets/example_t2v_prompt_short.txt \
    --output /tmp/upsampled_t2v_opus/ \
    --mode text2video \
    --endpoint-url "${PROMPT_UPSAMPLER_ENDPOINT_URL}" \
    --model "${PROMPT_UPSAMPLER_MODEL_NAME}" \
    --api-token "${PROMPT_UPSAMPLER_API_TOKEN}" \
    --resolution 720 \
    --aspect-ratio "16,9"

为方便使用,assets/example_t2v_prompt_short.txt 的 JSON 上采样版本已保存至 assets/example_t2v_prompt.json,并用于以下视频生成示例。

vLLM-Omni

容器

docker pull vllm/vllm-omni:cosmos3

通用调用

您可以使用经过发布测试的 vllm-omni 软件包来部署兼容 OpenAI 的 API 推理端点。 在 H200 上部署 nvidia/Cosmos3-Nano 时,推荐的 vLLM-Omni 服务配置如下:

vllm serve nvidia/Cosmos3-Nano \
  --omni \
  --host 0.0.0.0 \
  --port 8000 \
  --init-timeout 1800

若要借助额外的 GPU 加快推理速度,可使用 --ulysses-degree 启用上下文并行,或通过 --tensor-parallel-size 切换至张量并行。对于显存较少的 GPU,设置 --enable-layerwise-offload 有助于降低显存占用。

示例

下载示例提示词

示例输入(assets/)位于此模型仓库中。使用 Hugging Face CLI 仅下载该文件夹:

pip install -U "huggingface_hub[cli]"
hf download nvidia/Cosmos3-Nano assets/ --local-dir Cosmos3-Nano
cd Cosmos3-Nano

请在下载的仓库根目录下运行以下所有命令。


图像转视频生成
import json
import mimetypes
from pathlib import Path

import requests

# 1. Read JSON-upsampled prompt and negative prompt
json_prompt = json.load(open("assets/example_i2v_prompt.json"))
negative_prompt = json.load(open("assets/negative_prompt.json"))

# 2. Build and send the multipart API request
url = "http://localhost:8000/v1/videos/sync"
image_path = Path("assets/example_i2v_input.jpg")
mime_type = mimetypes.guess_type(image_path)[0] or "image/png"
data = {
    "prompt": json.dumps(json_prompt),
    "negative_prompt": json.dumps(negative_prompt),
    "size": "1280x720",
    "num_frames": "189",
    "fps": "24",
    "num_inference_steps": "35",
    "guidance_scale": "6.0",
    "max_sequence_length": "4096",
    "flow_shift": "10.0",
    "extra_params": json.dumps(
        {
          "use_resolution_template": False,
          "use_duration_template": False,
          "guardrails": True,
        }
    ),
    "seed": "1111",
}

with image_path.open("rb") as image_file:
    files = {
        "input_reference": (image_path.name, image_file, mime_type),
    }
    print("Sending request to server...")
    response = requests.post(
        url,
        data=data,
        files=files,
        headers={"Accept": "video/mp4"},
    )
    response.raise_for_status()

# 3. Save the generated video
output_path = Path("/tmp/cosmos3_nano_i2v.mp4")
output_path.write_bytes(response.content)
print(f"Saved video to {output_path}")

示例输出:


文本生成视频
import json
from pathlib import Path

import requests

# 1. Read JSON-upsampled prompt and negative prompt
json_prompt = json.load(open("assets/example_t2v_prompt.json"))
negative_prompt = json.load(open("assets/negative_prompt.json"))

# 2. Build your API payload
data = {
    "prompt": json.dumps(json_prompt),
    "negative_prompt": json.dumps(negative_prompt),
    "size": "1280x720",
    "num_frames": "189",
    "fps": "24",
    "num_inference_steps": "35",
    "guidance_scale": "6.0",
    "max_sequence_length": "4096",
    "flow_shift": "10.0",
    "extra_params": json.dumps(
        {
          "use_resolution_template": False,
          "use_duration_template": False,
          "guardrails": True,
        }
    ),
    "seed": "123",
}

# 3. Send the POST request
url = "http://localhost:8000/v1/videos/sync"
print("Sending request to server...")
response = requests.post(
    url,
    data=data,
    headers={"Accept": "video/mp4"},
)
response.raise_for_status()

# 4. Save the generated video
output_path = Path("/tmp/cosmos3_nano_t2v.mp4")
output_path.write_bytes(response.content)
print(f"Saved video to {output_path}")

示例输出:


图像转视频 + 音频生成
import json
import mimetypes
from pathlib import Path

import requests

# 1. Read JSON-upsampled prompt and negative prompt
json_prompt = json.load(open("assets/example_i2v_prompt.json"))
negative_prompt = json.load(open("assets/negative_prompt.json"))

# 2. Build and send the multipart API request
url = "http://localhost:8000/v1/videos/sync"
image_path = Path("assets/example_i2v_input.jpg")
mime_type = mimetypes.guess_type(image_path)[0] or "image/png"
data = {
    "prompt": json.dumps(json_prompt),
    "negative_prompt": json.dumps(negative_prompt),
    "size": "1280x720",
    "num_frames": "189",
    "fps": "24",
    "num_inference_steps": "35",
    "guidance_scale": "6.0",
    "max_sequence_length": "4096",
    "generate_sound": "true",
    "sound_duration": "7.875",
    "flow_shift": "10.0",
    "extra_params": json.dumps(
        {
          "use_resolution_template": False,
          "use_duration_template": False,
          "guardrails": True,
        }
    ),
    "seed": "0",
}

with image_path.open("rb") as image_file:
    files = {
        "input_reference": (image_path.name, image_file, mime_type),
    }
    print("Sending request to server...")
    response = requests.post(
        url,
        data=data,
        files=files,
        headers={"Accept": "video/mp4"},
    )
    response.raise_for_status()

# 3. Save the generated video
output_path = Path("/tmp/cosmos3_nano_i2vs.mp4")
output_path.write_bytes(response.content)
print(f"Saved video to {output_path}")

示例输出:


文本到视频+音频生成
import json
from pathlib import Path

import requests

# 1. Read JSON-upsampled prompt and negative prompt
json_prompt = json.load(open("assets/example_t2vs_prompt.json"))
negative_prompt = json.load(open("assets/negative_prompt.json"))

# 2. Build your API payload
data = {
    "prompt": json.dumps(json_prompt),
    "negative_prompt": json.dumps(negative_prompt),
    "size": "1280x720",
    "num_frames": "189",
    "fps": "24",
    "num_inference_steps": "35",
    "guidance_scale": "6.0",
    "max_sequence_length": "4096",
    "generate_sound": "true",
    "sound_duration": "7.875",
    "flow_shift": "10.0",
    "extra_params": json.dumps(
        {
          "use_resolution_template": False,
          "use_duration_template": False,
          "guardrails": True,
        }
    ),
    "seed": "0",
}

# 3. Send the POST request
url = "http://localhost:8000/v1/videos/sync"
print("Sending request to server...")
response = requests.post(
    url,
    data=data,
    headers={"Accept": "video/mp4"},
)
response.raise_for_status()

# 4. Save the generated video
output_path = Path("/tmp/cosmos3_nano_t2vs.mp4")
output_path.write_bytes(response.content)
print(f"Saved video to {output_path}")

示例输出:


动作生成

正向动力学示例使用 AgiBotWorld-Beta 机器人动作轨迹,逆向动力学示例使用自动驾驶汽车(AV)动作轨迹。源文件:

  • 正向动力学首帧:assets/example_action_fd_agibotworld_first_frame.png
  • 正向动力学动作块:assets/example_action_fd_agibotworld_action_chunks.json
  • 正向动力学输出视频:assets/example_action_fd_agibotworld_4chunk_output.mp4
  • 逆向动力学源视频:assets/example_action_id_av_0_input.mp4、assets/example_action_id_av_1_input.mp4
  • 逆向动力学预测动作:assets/example_action_id_av_0_output.json、assets/example_action_id_av_1_output.json
动作正向动力学

以下示例通过 vLLM-Omni /v1/videos/sync 推理端点执行 4 块 AgiBotWorld-Beta 机器人推演。每个请求通过 input_reference 发送一个条件帧,并通过 extra_params["action"] 发送一个 16 步归一化 29 维动作块。请求还将顶级 size 字段设置为输入图像分辨率,因此 vLLM-Omni 返回的每个块与条件图像分辨率相同,且无反射填充。拼接后的输出会丢弃每个块的条件帧,生成 64 帧。脚本从每个块中提取最后一帧生成帧,并将其用作下一个块的条件帧。

import json
import mimetypes
from pathlib import Path

import imageio.v3 as iio
import numpy as np
import requests
from PIL import Image

url = "http://localhost:8000/v1/videos/sync"
first_frame_path = Path("assets/example_action_fd_agibotworld_first_frame.png")
action_spec = json.loads(Path("assets/example_action_fd_agibotworld_action_chunks.json").read_text())
action_chunks = action_spec["action_chunks"]

prompt = action_spec.get("prompt", "Pickup items in the supermarket")
fps = int(action_spec.get("fps", 10))
action_chunk_size = int(action_spec.get("action_chunk_size", 16))
current_frame_path = first_frame_path
input_width, input_height = Image.open(first_frame_path).size
chunk_video_paths = []
stitch_frames = []

for chunk_idx, action_chunk in enumerate(action_chunks):
    mime_type = mimetypes.guess_type(current_frame_path)[0] or "image/png"
    extra_params = {
        "action_mode": "forward_dynamics",
        "domain_name": action_spec.get("domain_name", "agibotworld"),
        "action_chunk_size": action_chunk_size,
        "image_size": action_spec.get("image_size", 480),
        "view_point": action_spec.get("view_point", "concat_view"),
        "action": action_chunk,
        "guardrails": True,
    }
    data = {
        "prompt": prompt,
        "num_frames": str(action_chunk_size + 1),  # conditioning frame + generated frames
        "fps": str(fps),
        "size": f"{input_width}x{input_height}",  # return chunks at input resolution
        "num_inference_steps": "30",
        "guidance_scale": "1.0",
        "flow_shift": "10.0",
        "seed": "0",
        "extra_params": json.dumps(extra_params),
    }

    with current_frame_path.open("rb") as image_file:
        files = {"input_reference": (current_frame_path.name, image_file, mime_type)}
        print(f"Sending action FD chunk {chunk_idx} to vLLM-Omni...")
        response = requests.post(
            url,
            data=data,
            files=files,
            headers={"Accept": "video/mp4"},
            timeout=600,
        )
        response.raise_for_status()

    chunk_video_path = Path(f"/tmp/cosmos3_nano_action_fd_chunk_{chunk_idx:02d}.mp4")
    chunk_video_path.write_bytes(response.content)
    chunk_video_paths.append(chunk_video_path)

    # The returned chunk contains the conditioning frame followed by generated frames.
    # Drop the conditioning frame when stitching the generated-only rollout.
    frames = iio.imread(chunk_video_path)
    stitch_frames.extend(frames[1:])

    # Autoregressive conditioning: use the final generated frame from this chunk
    # as the input image for the next vLLM-Omni request.
    if chunk_idx + 1 < len(action_chunks):
        current_frame_path = Path(f"/tmp/cosmos3_nano_action_fd_ar_frame_{chunk_idx + 1:02d}.png")
        iio.imwrite(current_frame_path, frames[-1])

stitched_path = Path("/tmp/cosmos3_nano_action_fd_agibotworld_4chunk.mp4")
iio.imwrite(stitched_path, np.asarray(stitch_frames), fps=fps)
print("Generated chunk videos:", chunk_video_paths)
print("Saved stitched rollout:", stitched_path)
print("stitched resolution:", f"{input_width}x{input_height}")

示例输出:

动作逆动力学
import json
import time
from pathlib import Path

import requests

base_url = "http://localhost:8000"
input_videos = {
    "av_inverse_0": Path("assets/example_action_id_av_0_input.mp4"),
    "av_inverse_1": Path("assets/example_action_id_av_1_input.mp4"),
}

for name, video_path in input_videos.items():
    extra_params = {
        "action_mode": "inverse_dynamics",
        "domain_name": "av",
        "action_chunk_size": 60,
        "image_size": 480,
        "view_point": "ego_view",
        "raw_action_dim": 9,
        "guardrails": True,
    }
    data = {
        "prompt": "You are an autonomous vehicle planning system.",
        "num_frames": "61",
        "fps": "10",
        "num_inference_steps": "30",
        "guidance_scale": "1.0",
        "flow_shift": "10.0",
        "seed": "0",
        "extra_params": json.dumps(extra_params),
    }

    with video_path.open("rb") as video_file:
        files = {
            "input_reference": (video_path.name, video_file, "video/mp4"),
        }
        print(f"Submitting {name} request to server...")
        response = requests.post(f"{base_url}/v1/videos", data=data, files=files)
        response.raise_for_status()
    initial = response.json()

    while True:
        response = requests.get(f"{base_url}/v1/videos/{initial['id']}", timeout=30)
        response.raise_for_status()
        final = response.json()
        print(initial["id"], final.get("status"), f"{final.get('progress', 0)}%")
        if final.get("status") == "completed":
            break
        if final.get("status") in {"failed", "cancelled"}:
            raise RuntimeError(json.dumps(final, indent=2))
        time.sleep(2)

    action = final.get("action")
    if not action or "data" not in action:
        raise RuntimeError(f"Response did not include action data: {json.dumps(final, indent=2)}")

    output_path = Path(f"/tmp/cosmos3_nano_action_id_{name}.json")
    output_path.write_text(json.dumps(action, indent=2))
    print(f"Saved predicted action to {output_path}")
    print("action shape:", action.get("shape"), "dtype:", action.get("dtype"))

示例输出:

  • av_inverse_0 预测动作 JSON
  • av_inverse_1 预测动作 JSON

vLLM

通用调用

您可以使用经过发布测试的 vllm 软件包来部署兼容 OpenAI 的 API 端点:

uv venv --python 3.13 --seed --managed-python
source .venv/bin/activate
uv pip install --torch-backend=cu130 "vllm==0.21.0" \
  "vllm-cosmos3 @ git+https://github.com/NVIDIA/cosmos-framework.git#subdirectory=packages/vllm-cosmos3" \
  openai

对于 CUDA 13 驱动程序,请使用 --torch-backend=cu130 "vllm==0.21.0"。对于 CUDA 12.8 驱动程序,请使用 --torch-backend=cu128 "vllm==0.19.1"。

启动 Reasoner 服务器:

CUDA_VISIBLE_DEVICES=0 \
vllm serve nvidia/Cosmos3-Nano \
  --hf-overrides '{"architectures": ["Cosmos3ReasonerForConditionalGeneration"]}' \
  --tensor-parallel-size 1 \
  --mm-encoder-tp-mode data \
  --async-scheduling \
  --allowed-local-media-path / \
  --media-io-kwargs '{"video": {"num_frames": -1}}' \
  --port 8000

示例

推理

从模型仓库根目录运行此示例。它会从 assets/example_reasoning_prompt.json 读取机器人规划提示,并将 assets/example_reasoning_input.png 发送到本地 vLLM 服务器。

import json
from pathlib import Path

import openai

# 1. Read the image reasoning prompt
example = json.load(open("assets/example_reasoning_prompt.json"))
image_path = Path("assets/example_reasoning_input.png").resolve()
image_url = image_path.as_uri()

# 2. Query the OpenAI-compatible vLLM server
client = openai.OpenAI(
    api_key="EMPTY",
    base_url="http://localhost:8000/v1",
)

response = client.chat.completions.create(
    model=client.models.list().data[0].id,
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "image_url", "image_url": {"url": image_url}},
                {"type": "text", "text": example["prompt"]},
            ],
        },
    ],
    max_tokens=example["max_tokens"],
    seed=0,
)

# 3. Print the generated reasoning output
print(response.choices[0].message.content)

示例输入:

提示词:

The task is to put flower into the red bottle. Generate a plan consisting of subtasks for accomplish the task.

上述命令的示例输出:

Move your arm to the flower. Grasp the flower. Move your arm to the red bottle. Place the flower in the red bottle.

Diffusers

Cosmos3 已在广受欢迎的 HuggingFace Diffusers 软件包中得到全面支持。此集成使其成为受支持的推理后端,让开发者能够轻松将 Cosmos3 的功能(如文本到视频生成)整合到自己的工作流中,只需使用 Cosmos3OmniPipeline 类即可,具体可参考所提供的代码示例(其他模态的示例请参见 HuggingFace Cosmos3 页面)。

容器

如需安装带有 Cosmos3OmniPipeline 的 diffusers:

uv venv --python 3.13 --seed --managed-python
source .venv/bin/activate
uv pip install \
  "diffusers @ git+https://github.com/huggingface/diffusers.git" \
  accelerate \
  av \
  cosmos_guardrail \
  huggingface_hub \
  imageio \
  imageio-ffmpeg \
  torch \
  torchvision \
  transformers

示例

文本转视频生成

从模型仓库根目录运行此示例。它会从assets/example_t2v_prompt.json读取JSON格式的上采样提示词,并从assets/negative_prompt.json读取负面提示词。随后加载管道并生成视频,最后将其保存为MP4文件。

import json
import torch
from diffusers import Cosmos3OmniPipeline
from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
from diffusers.utils import export_to_video

# Read JSON-upsampled prompt and negative prompt
json_prompt = json.load(open("assets/example_t2v_prompt.json"))
negative_prompt = json.load(open("assets/negative_prompt.json"))

pipe = Cosmos3OmniPipeline.from_pretrained(
    "nvidia/Cosmos3-Nano",
    torch_dtype=torch.bfloat16,
    device_map="cuda",
    enable_safety_checker=True,
)
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=10.0)

result = pipe(
    prompt=json.dumps(json_prompt),
    negative_prompt=json.dumps(negative_prompt),
    num_frames=189,
    height=720,
    width=1280,
    num_inference_steps=35,
    guidance_scale=6.0,
    generator=torch.Generator(device="cuda").manual_seed(123),
)

export_to_video(result.video, "/tmp/cosmos3_nano_t2v_diffusers.mp4", fps=24)
print("Saved video to /tmp/cosmos3_nano_t2v_diffusers.mp4")

示例输出:

局限性

在复杂场景下,Cosmos3 可能会生成不尽完美的输出。生成缺陷包括时间不一致性、不稳定的相机或物体运动、不精确的物理交互、不准确的音视频同步以及动作状态偏移——尤其是在长时程或高分辨率输出中。推理过程也可能存在错误:物体状态、因果关系、空间几何、时间顺序、主体意图和未来结果可能被错误推断;复杂或长上下文输入可能导致虚构实体、不一致的解释或不合理的预测。由于模型缺乏显式的物理模拟器,3D 几何、4D 时空演化、物体恒存性、接触动力学和物理定律仅为近似模拟——这会产生诸如物体消失或变形、不真实的碰撞以及物理上不合理的运动等缺陷。在分布外环境、安全关键边缘案例以及训练中代表性不足的领域,生成质量会进一步下降。

Cosmos3 的输出不应被视为物理精确的模拟、可靠的事实推理或安全认证的决策依据。涉及机器人控制、自主系统、科学模拟或安全关键规划的应用,在部署前需要额外的验证、外部约束、系统级安全分析以及特定领域的防护措施。

推理

加速引擎: PyTorch、vLLM、vLLM-Omni、Hugging Face Diffusers

测试硬件: GB200 和 H100

伦理考量

NVIDIA 认为可信 AI 是一项共同责任,我们已制定相关政策和实践,以支持广泛 AI 应用的开发。开发者应与内部模型团队合作,确保该模型满足相关行业和用例的要求,并应对未预见的产品误用问题。

请确保您对所有输入图像和视频内容拥有适当的权利和许可;如果图像或视频中包含人物、个人健康信息或知识产权,生成的图像或视频不会模糊或保持所包含图像主体的比例。

用户对模型的输入和输出负责。用户负责确保在部署前对该模型进行安全集成,包括实施防护措施以及其他安全机制。

有关此模型伦理考量的更多详细信息,请参见 Model Card++ 的可解释性、偏差、安全与安保和隐私子卡片。请通过此处报告模型质量、风险、安全漏洞或 NVIDIA AI 相关问题。