原模型:HuggingFaceVLA/smolvla_libero(HuggingFace / GitCode 镜像)
torch.cuda / .cuda() / device='cuda' 调用,
模型与输入统一迁移 npu:0。torch.npu.set_device(0) 包在 try-except 中,失败即抛明确错误。is_torch_device_available /
get_safe_torch_device / auto_select_torch_device / is_amp_available 识别 npu 设备,
使 config.device 自动回退为 npu:0。device_processor 覆盖为 npu:0,tokenizer 走本地 VLM 组件。vlm_deps/,
推理时不依赖外网。model.safetensors 全量加载覆盖。| 模态 | 键名 | 形状 | 说明 |
|---|---|---|---|
| 输入 | observation.images.image | (3, 256, 256) | 相机图像 (C,H,W),值域 [0,1] |
| 输入 | observation.images.image2 | (3, 256, 256) | 第二相机图像 (C,H,W),值域 [0,1] |
| 输入 | observation.state | (8,) | 机器人关节状态向量 |
| 输入 | task | str | 语言指令(默认 "pick up the black bowl and place it on the plate") |
| 输出 | action | (7,) | 单步动作 |
| 输出 | action chunk | (50, 7) | 动作序列 chunk |
权重缓存目录:
./model_weights/HuggingFaceVLA/smolvla_libero(本地,不入库) 归一化统计量已内嵌于policy_preprocessor_*/policy_postprocessor_*,推理脚本自动加载。
pip install -r requirements.txtpython3 download_weights.pypython3 inference.py \
--img test_images/image.png \
--img-image2 test_images/image2.png \
--state "0,0,0,0,0,0,0,0" \
--task "pick up the black bowl and place it on the plate"输出示例:
{
"status": "success",
"model": "HuggingFaceVLA/smolvla_libero",
"device": "npu:0",
"task": "pick up the black bowl and place it on the plate",
"action": [0.05, -0.12, 0.30, -0.18, 0.06, -0.02, 0.50],
"action_dim": 7,
"action_chunk_size": 50
}python3 -m uvicorn inference:app --host 0.0.0.0 --port 8000调用推理接口:
curl -s -X POST http://127.0.0.1:8000/predict \
-F "image=@test_images/image.png" \
-F "image2=@test_images/image2.png" \
-F "state=0,0,0,0,0,0,0,0" \
-F "task=pick up the black bowl and place it on the plate"| 文件 | 说明 |
|---|---|
inference.py | NPU 推理主脚本(CLI + FastAPI 双模式,共用同一套 NPU 加载/推理逻辑) |
download_weights.py | 权重下载脚本(本地缓存,命中跳过) |
make_screenshots.py | 取证截图生成脚本(assets/*.png) |
assets/ | 取证截图(agent_workflow.png / npu_device_call.png / model_result.png) |
vlm_deps/ | SmolVLM2 VLM 组件本地缓存(config/tokenizer/processor) |
test_images/ | 示例测试图像(LIBERO 机器人工作台场景) |