cosmos系列模型的推理使用——cosmos transfer2.5

我们先来使用cosmos transfer2.5来进行基本的功能推理。之前已经用过cosmos-transfer1的功能了,所以对一些基本内容还是比较熟悉了,这次我们主要解决cosmos2上遇到的一些问题。

首先还是先下载源码,通过git lfs来拉取。

bash 复制代码
sudo apt install git-lfs
git lfs install
bash 复制代码
git clone https://github.com/nvidia-cosmos/cosmos-transfer2.5.git
cd cosmos-transfer2.5
git lfs pull
bash 复制代码
sudo apt update && sudo apt -y install curl ffmpeg libx11-dev tree wget
bash 复制代码
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
bash 复制代码
uv python install # 注意版本,cosmos2不再限制python的3.12,只需要3.10即可
uv sync --extra=cu128
source .venv/bin/activate

以上下载是比较慢的,需要多等待。另外,如果是先要把环境安装到当前的conda环境,也是可以用命令uv sync --extra=cu128 --active --inexact实现的,但是比较麻烦,不太推荐了。这样我们就把运行的python环境都配置好了。

接下来我们测试相关的功能

bash 复制代码
python examples/inference.py -i assets/robot_example/depth/robot_depth_spec.json -o outputs/depth

python examples/inference.py \
  -i assets/robot_example/depth/robot_depth_spec.json \
  -o outputs/depth2

python examples/inference.py -i assets/robot_example/edge/robot_edge_spec.json -o outputs/edge

python examples/inference.py -i assets/robot_example/seg/robot_seg_spec.json -o outputs/seg

python examples/inference.py -i assets/robot_example/vis/robot_vis_spec.json -o outputs/vis

python examples/inference.py -i assets/robot_example/multicontrol/robot_multicontrol_spec.json -o outputs/multicontrol
bash 复制代码
# 汽车场景
# Depth 控制 - 汽车
python examples/inference.py -i assets/car_example/depth/car_depth_spec.json -o outputs/car_depth

# Edge 控制 - 汽车
python examples/inference.py -i assets/car_example/edge/car_edge_spec.json -o outputs/car_edge

# Segmentation 控制 - 汽车
python examples/inference.py -i assets/car_example/seg/car_seg_spec.json -o outputs/car_seg

# Blur 控制 - 汽车
python examples/inference.py -i assets/car_example/vis/car_vis_spec.json -o outputs/car_vis

# 多控制 - 汽车
python examples/inference.py -i assets/car_example/multicontrol/car_multicontrol_spec.json -o outputs/car_multicontrol
bash 复制代码
# 8卡并行推理(单控制或多控制变体)
torchrun --nproc_per_node=8 --master_port=12341 \
  examples/inference.py \
  -i assets/robot_example/depth/robot_depth_spec.json \
  -o outputs/depth_8gpu

# 自定义GPU数量
torchrun --nproc_per_node=4 --master_port=12341 \
  examples/inference.py \
  -i assets/robot_example/multicontrol/robot_multicontrol_spec.json \
  -o outputs/multicontrol_4gpu
bash 复制代码
# 图像推理
# 单帧图像转换
python examples/inference.py -i assets/image_example/image2image.json -o outputs/image2image
# 使用参考图像引导视频生成
python examples/inference.py -i assets/image_example/image_style.json -o outputs/image_style

# 多GPU版本
torchrun --nproc_per_node=8 --master_port=12341 \
  examples/inference.py \
  -i assets/image_example/image_style.json \
  -o outputs/image_style
bash 复制代码
# 生成多视角所需的视频
python scripts/generate_control_videos.py -i assets/multiview_example1/scene_annotations -o outputs/multiview_example1_world_scenario_videos


# 多相机视角同步生成(front_wide, rear_left, rear_right等7个视角)
torchrun --nproc_per_node=8 --master_port=12341 \
  examples/multiview.py \
  -i assets/multiview_example/multiview_spec.json \
  -o outputs/multiview

# 自回归多视角生成长视频
torchrun --nproc_per_node=8 --master_port=12341 \
  -m examples.multiview \
  -i assets/multiview_example/multiview_autoregressive_spec.json \
  -o outputs/multiview_autoregressive
bash 复制代码
# 查看所有参数说明
python examples/inference.py --help

# 查看特定控制类型的参数
python examples/inference.py control:edge --help
python examples/inference.py control:depth --help
python examples/inference.py control:seg --help
python examples/inference.py control:vis --help

# 多视角帮助
python examples/multiview.py --help
python examples/multiview.py control:view-config --help

新版本的最重要的是可以生成更加合理的多视角视频了,这里我们资源不足,多模态的控制模式的生成是没有问题的。

单一模态

多模态

相关推荐
Dlrb12111 天前
C语言-指针三
c语言·算法·指针·const·命令行参数
Tisfy1 天前
LeetCode 2540.最小公共值:双指针(O(m+n))
算法·leetcode·题解·双指针
IronMurphy1 天前
【算法四十七】152. 乘积最大子数组
算法
淘矿人1 天前
Claude辅助DevOps实践
java·大数据·运维·人工智能·算法·bug·devops
Cosolar1 天前
万字详解:RAG 向量索引算法与向量数据库架构及实战
数据库·人工智能·算法·数据库架构·milvus
绵满1 天前
"Sample Is Feature: Beyond Item-Level, Toward Sample-Level Tokens for Unified Large Recommender Models" 论文笔记
大模型·推荐系统
落羽的落羽1 天前
【算法札记】练习 | Week4
linux·服务器·数据结构·c++·人工智能·算法·动态规划
山屿落星辰1 天前
昇腾NPU上的FlashAttention:让大模型“算得快“又“记得准“
大模型
萑澈1 天前
算法竞赛入门:C++ STL核心用法与时空复杂度速查手册
数据结构·c++·算法·stl