原模型:edge-inference/smolvla-so101-pick-orange(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/,
推理时不依赖外网。| 模态 | 键名 | 形状 | 说明 |
|---|---|---|---|
| 输入 | observation.images.front | (3, 480, 640) | 前视相机图像 (C,H,W),值域 [0,1] |
| 输入 | observation.images.wrist | (3, 480, 640) | 腕部相机图像 (C,H,W),值域 [0,1] |
| 输入 | observation.state | (6,) | SO101 关节状态向量 |
| 输入 | task | str | 语言指令(默认 "Pick up the orange and place it on the plate") |
| 输出 | action | (6,) | 单步动作(关节位置,度) |
| 输出 | action chunk | (50, 6) | 动作序列 chunk |
权重缓存目录:
./model_weights/edge-inference/smolvla-so101-pick-orange(本地,不入库) 归一化统计量已内嵌于policy_preprocessor_*/policy_postprocessor_*,推理脚本自动加载。
pip install -r requirements.txtpython3 download_weights.pypython3 inference.py \
--img test_images/front.png \
--img-wrist test_images/wrist.png \
--state "0,0,0,0,0,0" \
--task "Pick up the orange and place it on the plate"输出示例:
{
"status": "success",
"model": "edge-inference/smolvla-so101-pick-orange",
"device": "npu:0",
"action": [5.77, -10.89, 15.50, 30.51, 4.16, 8.05],
"action_dim": 6,
"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 "front=@test_images/front.png" \
-F "wrist=@test_images/wrist.png" \
-F "state=0,0,0,0,0,0" \
-F "task=Pick up the orange 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/ | 示例测试图像(拾取橙子场景) |