本仓库将 lerobot/smolvla_metaworld(SmolVLA 视觉-语言-动作策略,Meta-World metaworld-push 任务微调版)适配到昇腾 (Ascend) NPU(torch-npu,设备 npu:0)。权重在首次使用时自动从镜像下载到 model_weights/lerobot/smolvla_metaworld/,无需手动干预。
lerobot/smolvla_base(VLM 主干 HuggingFaceTB/SmolVLM2-500M-Video-Instruct + 动作专家头)| 字段 | 值 |
|---|---|
| 模型 | lerobot/smolvla_metaworld |
| 架构 | SmolVLM2-500M 视觉语言主干(16 层文本层截断)+ 动作专家头(flow matching 采样,num_steps=10) |
| 任务 | Meta-World metaworld-push(“Push the puck to a goal”),动作 4 维(x, y, z, gripper) |
| 输入 | 单路顶部相机帧(训练为 480×480,推理时任意尺寸 resize 到 512×512 并填充)+ 4 维 agent state + 指令文本 |
| 输出 | 50 步动作块(chunk_size=50),每步 4 维;返回**真实(反归一化)**动作 |
| 归一化 | 图像 IDENTITY;state / action 均为 MEAN_STD(来自 checkpoint 的 pre/postprocessor) |
| 权重文件 | config.json、model.safetensors(约 906 MB)、policy_preprocessor.json、policy_preprocessor_step_5_normalizer_processor.safetensors、policy_postprocessor.json、policy_postprocessor_step_0_unnormalizer_processor.safetensors、train_config.json |
model_code/ 内 vendor 的 SmolVLA 源码)均无 .cuda() / torch.cuda / device="cuda";模型与所有输入张量都在 npu:0 上。init_npu() 中(try-except,失败输出 JSON 错误并退出)。hf-mirror.com),缓存于 model_weights/lerobot/smolvla_metaworld/;下载后对 safetensors 做 8 字节 header + JSON + 数据偏移 + NaN/Inf 校验。model_weights/vlm/SmolVLM2-500M-Video-Instruct/,只用其构建架构(不重复下载主干权重,主干权重已内含在 model.safetensors)。若 tokenizer.json 下载损坏,会自动跳过并使用慢速 GPT2Tokenizer 回退。model_code/ 收录了 HuggingFace LeRobot 仓库中 SmolVLA 策略源码(src/lerobot/policies/smolvla/* 与 src/lerobot/policies/common/{vla_utils,flow_matching}.py),做了 CUDA 清理与 LeRobot 依赖剥离。检查点加载:先按 config.json 构建 SmolVLAPolicy,再严格加载 model.safetensors(缺失/多余键数为 0,已验证)。ASCEND_RT_VISIBLE_DEVICES=0 python3 inference.py --img examples/demo_metaworld.png 2>cli.err | tee cli.log可选参数:
--instr "Grasp the block" 覆盖指令(默认:Push the puck to a goal)--state x,y,z,g 覆盖 4 维 agent state(默认使用数据集的 state 均值,归一化后≈0)输出 JSON 到 stdout(设备 npu:0):
{
"model": "lerobot/smolvla_metaworld",
"source": "https://ai.gitcode.com/hf_mirrors/lerobot/smolvla_metaworld",
"device": "npu:0",
"status": "success",
"instruction": "Push the puck to a goal",
"action": [x, y, z, gripper],
"action_dim": 4,
"chunk_size": 50,
"action_chunk": [[...], ...],
"elapsed_ms": 1234.56
}action / action_chunk 均为**真实(反归一化)**动作值(action_real = action_norm * std + mean)。
ASCEND_RT_VISIBLE_DEVICES=0 python3 inference.py --mode server --port 8785GET / — 最小化深色终端风格 HTML 上传页POST /predict — multipart 上传图片(file)+ 可选指令字段(instr)→ 同上 JSON示例:
curl -s -F file=@examples/demo_metaworld.png http://127.0.0.1:8785/predict
curl -s -F file=@examples/demo_metaworld.png -F "instr=Push the puck to a goal" http://127.0.0.1:8785/predictexamples/demo_metaworld.png 是从真实 Meta-World 数据集 lerobot/metaworld_mt50(data/chunk-000/file-000.parquet,episode 0,顶部相机 480×480 RGB 帧)中提取的真实机器人相机帧,非合成图片。
transformers==4.57.6 safetensors numpy Pillow fastapi uvicorn python-multipart num2wordsASCEND_RT_VISIBLE_DEVICES=0(代码内固定 npu:0)inference.py — 双模式推理入口(CLI + FastAPI,NPU 适配)model_code/ — vendored SmolVLA 策略源码(CUDA 已清理,无 LeRobot 依赖)make_screenshots.py — 生成验证截图examples/demo_metaworld.png — 真实 metaworld 顶部相机帧assets/ — 验证截图(agent_workflow / npu_device_call / model_result)@article{shukor2025smolvla,
title={SmolVLA: A Vision-Language-Action Model for Affordable and Efficient Robotics},
author={Shukor, Mustafa and Aubakirova, Dana and Capuano, Francesco and Kooijmans, Pepijn and Palma, Steven and Zouitine, Adil and Aractingi, Michel and Pascal, Caroline and Russi, Martino and Marafioti, Andres and Alibert, Simon and Cord, Matthieu and Wolf, Thomas and Cadene, Remi},
journal={arXiv preprint arXiv:2506.01844},
year={2025}
}