| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch / torch_npu | 2.1.0+ | NPU 上需安装 torch_npu(系统环境已含 2.7.1) |
| transformers | == 4.57.6 | 自定义代码(trust_remote_code=True)与 XVLAProcessor 支持;5.x 与 Florence-2 自定义 config 不兼容(已装至 libs) |
| huggingface_hub | < 1.0 | transformers 4.x 要求(0.36.0) |
| einops / timm | 最新版 | Florence-2 建模代码依赖(已装至 libs) |
| fastapi / uvicorn / json-numpy / opencv-python-headless | 最新版 | modeling_xvla.py 顶部硬依赖(已装至 libs) |
安装命令:
pip install --target /mnt/workspace/X-VLA-Pt/libs -i https://pypi.tuna.tsinghua.edu.cn/simple "transformers==4.57.6" "huggingface_hub==0.36.0" einops timm pillow numpy fastapi uvicorn json-numpy opencv-python-headless# 检查 NPU 设备
npu-smi info
# 权重已就位
ls /home/developer/models/X-VLA-Pt/ # config.json model.safetensors modeling_xvla.py processing_xvla.py ...PYTHONPATH=/mnt/workspace/X-VLA-Pt/libs python3 inference.py --model_path /home/developer/models/X-VLA-Pt脚本内置合成三视角桌面场景图(正视 + 腕部 + 侧视)、抓放指令、示例本体状态与域 ID,自动选择设备 npu > cuda > cpu,全程离线推理(local_files_only=True,自定义建模代码随权重目录经 trust_remote_code 本地加载)。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model_path | str | /home/developer/models/X-VLA-Pt | X-VLA 权重目录 |
| --instruction | str | pick up the black bowl on the stove and place it on the plate | 自然语言操作指令 |
| --domain_id | int | 0 | 本体/域 ID(0..29,对应训练时各数据集/本体) |
| --steps | int | 10 | Flow Matching Euler 积分去噪步数 |
| 环境变量 XVLA_DEVICE | str | 自动(npu > cuda > cpu) | 强制指定推理设备 |
输入:
python3 inference.py --model_path /home/developer/models/X-VLA-Pt输出:
使用设备: npu
instruction : pick up the black bowl on the stove and place it on the plate
domain_id : 0
输入视角数 : 3 / 3
flow matching 步数: 10
输出动作块 shape : (1, 30, 20) (batch, num_actions, dim_action)
首帧动作 : [...]
动作范围 : [...]
模型加载耗时: XX.XXX s
推理耗时: XX.XXX s
耗时/elapsed: XX.XXX s输入:
python3 inference.py --model_path /home/developer/models/X-VLA-Pt --instruction "open the drawer" --steps 20输出:
输出 (1, 30, 20) 动作块:每帧 20 维为双臂末端执行器动作 ee6d [xyz(3), rot6D(6), gripper(1)] × 双臂
耗时/elapsed: XX.XXX s


XVLA_DEVICE 环境变量强制指定;--model_path 加载(local_files_only=True),Florence-2 等自定义建模/预处理代码亦从本地权重目录加载(trust_remote_code),推理全程离线;ee6d:dim_action=20、num_actions=30(30 步动作块);proprio 维度同为 20;夹爪通道(索引 9/19)经 sigmoid 后处理;domain_id 取值范围 0..29(num_domains=30),不同本体需使用训练时对应的域 ID 才能获得有效策略;