模型名称: X-VLA-Libero (X-VLA 0.9B Libero Edition)
模型链接: 2toINF/X-VLA-Libero
模型描述: X-VLA 是一种 Vision-Language-Action (VLA) 模型,采用 Soft-Prompted Transformer 架构,用于跨机器 embodiment 的视觉-语言-动作学习。该模型基于 Florence-2 视觉-语言骨干网络,通过软提示(soft prompt)实现不同机器人平台间的知识迁移。在 Bridge Data 上训练,可在多种仿真环境和真实机器人上执行灵巧操作任务。
模型架构:
| 组件 | 角色 |
|---|---|
| Florence-2 Encoder | 视觉-语言表示骨干网络(encoder-only) |
| SoftPromptedTransformer | Flow-matching 动作去噪器,使用可学习的软提示 |
| Action Hub | 定义动作空间、掩码规则、预处理/后处理和损失函数 |
参数规模: ~0.9B
动作模式: ee6d(末端执行器 xyz + 6D旋转 + 双指夹爪,共 20 维动作)
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | 2.9.0 | PyTorch 框架 |
| torch_npu | 2.9.0 | 昇腾 NPU 支持(随 CANN 安装) |
| transformers | >= 4.44.0 | HuggingFace 模型加载 |
| timm | 最新 | 视觉编码器依赖 |
| Pillow | >= 9.0.0 | 图像处理 |
| numpy | >= 1.24.0 | 数组处理 |
| json-numpy | 最新 | JSON 序列化 |
| fastapi | 最新 | FastAPI 服务(可选) |
| uvicorn | 最新 | ASGI 服务器(可选) |
| 昇腾驱动 | CANN 8.5.1 | 昇腾芯片驱动及工具包 |
安装命令:
pip install torch torch_npu transformers timm Pillow numpy json-numpytorch_npu 说明: torch_npu 需通过昇腾 CANN (Compute Architecture for Neural Networks) 工具包安装,而非普通 pip 安装。请参考 昇腾官方文档 完成安装。
# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch_npu.__version__); import torch; print(torch.npu.is_available())"# 单条输入推理(使用文字指令 + 可选图片)
python inference.py \
--model_path /tmp/X-VLA-Libero \
--input "Pick up the red block on the table" \
--max_length 50 \
--num_steps 10 \
--domain_id 0
# 使用图片输入(最多3个相机视角)
python inference.py \
--model_path /tmp/X-VLA-Libero \
--input "Pick up the red block" \
--image camera_0.jpg \
--image1 camera_1.jpg \
--image2 camera_2.jpg \
--num_steps 10 \
--domain_id 0
# 从文件批量读取输入
python inference.py \
--model_path /tmp/X-VLA-Libero \
--input_file test_samples.txt \
--max_length 50 \
--num_steps 10| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--input | str | - | 语言指令文本(与 --input_file 二选一) |
--input_file | str | - | 包含输入的文本文件路径 |
--model_path | str | 必填 | 本地模型权重路径 |
--max_length | int | 50 | 文本最大 token 长度 |
--num_steps | int | 10 | Flow-matching 去噪步数(越多越精确但越慢) |
--domain_id | int | 0 | 机器人 embodiment 域 ID |
--image | str | - | 第一个相机视角图片路径 |
--image1 | str | - | 第二个相机视角图片路径 |
--image2 | str | - | 第三个相机视角图片路径 |
输入:
语言指令: Pick up the red block on the table
相机图像: 3 个视角的 RGB 图像(224x224,默认使用灰色占位图)输出:
[INFO] Using device: npu:0
[INFO] Loading model from: /tmp/X-VLA-Libero
[INFO] Input text: Pick up the red block on the table
[INFO] Running NPU inference...
[RESULT] Inference completed in 0.390s
[RESULT] Device: npu:0
[RESULT] Action shape: (30, 20)
[RESULT] Action values (first 10 dims):
[-0.033, -0.127, 0.213, 0.114, -0.179, 0.141,
0.043, -0.019, -0.448, 0.403, ...]动作向量说明:



| 测试项 | 结果 |
|---|---|
| NPU 设备可用 | ✅ Ascend910 (2 芯片) |
| torch_npu 版本 | 2.9.0.post1+gitee7ba04 |
| CANN 版本 | 8.5.1 |
| 模型加载 | ✅ 成功(X-VLA 0.9B,~3.5GB) |
| 多模态编码 | ✅ Florence-2 视觉-语言编码正常 |
| 动作生成 | ✅ Flow-matching 去噪推理成功 |
| 输出维度 | ✅ (30, 20) - 30 步动作序列,20 维动作空间 |
| 推理耗时 | ✅ ~0.39s (NPU:0) |
结论: X-VLA-Libero 模型已成功在昇腾 NPU (Ascend910) 上完成推理验证,可正常执行视觉-语言-动作推理流程。
NPU 引擎: 推理脚本通过 torch_npu 调用昇腾 NPU 进行推理,使用 .to("npu:0") 将模型和张量放到 NPU 设备。
模型加载: 必须使用 trust_remote_code=True 加载自定义的 XVLA 模型类(XVLAConfig、XVLA、XVLAProcessor),这些类定义在模型仓库的 modeling_xvla.py、configuration_xvla.py、processing_xvla.py 中。
图片输入: 模型支持最多 3 个相机视角的 RGB 图像。如果未提供图片,推理脚本会使用灰色占位图进行演示,实际使用时应提供真实相机图像。
动作输出: 模型输出 30 步动作序列(30 timesteps),每步 20 维动作向量(ee6d 模式:xyz位置 + 6D旋转 + 双指夹爪)。动作需要经过 postprocess 处理(如夹爪通道 sigmoid)后才能用于机器人控制。
精度说明: 模型权重使用 float32 精度,NPU 推理无需精度校准即可正常运行。
依赖安装顺序: 建议先安装 CANN 工具包(包含 torch_npu),再安装其他 Python 依赖。transformers 版本建议使用 4.44.0(与模型代码兼容)。
内存需求: 模型约 3.5GB,推理时 NPU 内存占用约 4-6GB,请确保 NPU 设备有足够 HBM 空间。