f
gcw_pCMO8DfP/smolvla_base
模型介绍
文件和版本
Pull Requests
讨论
分析

SmolVLA-Base — 视觉语言动作模型 (昇腾 NPU 版)

SmolVLA 是 LeRobot 推出的紧凑视觉语言动作 (Vision-Language-Action, VLA) 策略,基于 SmolVLM2-500M 视觉语言底座 + 动作专家模块,通过 flow-matching 采样直接输出机器人动作 chunk。本仓库为 昇腾 Ascend NPU (torch_npu) 适配版,全流程无 CUDA。

环境要求

  • Python 3.10+
  • 昇腾 NPU (Ascend910) + torch_npu 2.9 + CANN
  • 依赖: torch 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