SmolVLA 是 LeRobot 推出的紧凑视觉语言动作 (Vision-Language-Action, VLA) 策略,基于 SmolVLM2-500M 视觉语言底座 + 动作专家模块,通过 flow-matching 采样直接输出机器人动作 chunk。本仓库为 昇腾 Ascend NPU (torch_npu) 适配版,全流程无 CUDA。
torch_npu 2.9 + CANNtorch torch_npu transformers fastapi uvicorn python-multipart safetensors pillow numpy# 命令行单图推理 (VLA: 图像 + 指令 -> 动作 chunk)
python3 inference.py --img sample_input.png --text "perform the task in the scene"
# 启动 FastAPI 服务 (根路径为上传表单, POST /predict 返回推理 JSON)
python3 inference.py --server| 参数 | 说明 |
|---|---|
--img | 机器人相机图像路径 (必需) |
--text | 语言指令, 默认 perform the task in the scene |
--state | 机器人状态向量 (逗号分隔, 默认全零) |
--server | 启动 FastAPI Web 服务 |
{
"model": "lerobot/smolvla_base",
"device": "npu:0",
"instruction": "perform the task in the scene",
"action_dim": 6,
"chunk_size": 50,
"inference_time_s": 3.21,
"action_chunk": [[0.012, -0.003, ...], ...]
}策略权重与 SmolVLM2-500M-Video-Instruct 处理器文件自动从 GitCode 镜像下载,缓存到 ./model_weights/,优先复用本地缓存。
smolvla_base/
├── inference.py # 主推理脚本 (CLI + FastAPI 双模式)
├── lerobot/ # vendored SmolVLA 策略模块 (NPU 适配, 无 CUDA)
├── sample_input.png # 示例输入图像
├── README.md
├── model_weights/ # 权重缓存 (symlink 到共享缓存)
└── assets/ # 截图
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png