原模型:nvidia/Alpamayo-R1-10B(NVIDIA 自动驾驶 Vision-Language-Action 模型)
torch.cuda / .cuda() / device='cuda' 调用,
模型与输入统一迁移 npu:0;alpamayo1_5 代码包内的 torch.cuda.empty_cache() 已改写为
torch.npu.empty_cache()。torch.npu.set_device(0) 包在 try-except 中,失败即抛明确错误。backbone/Cosmos-Reason2-8B/,tokenizer vocab=151669,加 4000 轨迹 token + 28 特殊
token 后 vocab=155697,与权重/config 完全一致;推理不依赖外网。attn_implementation=flash_attention_2 改为 sdpa(NPU 原生支持)。model_type=alpamayo_r1 / _target_=alpamayo_r1.* 适配为
alpamayo1_5 代码包可加载格式(hydra target 前缀改写),权重从本地 model_weights/ 加载。| 模态 | 键名 | 形状 | 说明 |
|---|---|---|---|
| 输入 | 相机图像 | (1,3,H,W) uint8 | 前视相机图像 |
| 输入 | ego_history_xyz | (1,1,16,3) | ego 历史轨迹(1.6s @10Hz,本地位移坐标系) |
| 输入 | ego_history_rot | (1,1,16,3,3) | ego 历史姿态(旋转矩阵) |
| 输出 | trajectory.xyz | (64,3) | 未来 6.4s 轨迹航点(米,本地位移坐标系) |
| 输出 | trajectory.rot | (64,3,3) | 未来轨迹姿态 |
| 输出 | waypoints | list[64] | {x,y,z} 航点列表 |
| 输出 | reasoning | str | Chain-of-Causation 驾驶推理文本 |
权重缓存目录:
./model_weights/nvidia/Alpamayo-R1-10B(约 22GB,不入库,由download_weights.py下载)。
torch==2.9.0、transformers==4.57.6(Qwen3-VL 原生支持)、torch_npurequirements.txtpython3 download_weights.pypython3 inference.py --img test_images/front_camera.png输出轨迹 JSON:status/model/device/trajectory/waypoints。
uvicorn inference:app --host 0.0.0.0 --port 8000curl -X POST http://127.0.0.1:8000/predict -F "file=@test_images/front_camera.png"inference.py:CLI + FastAPI 双模式 NPU 推理(CUDA 清零 + NPU 迁移)download_weights.py:GitCode HF 镜像权重下载(WAF 429 退避)alpamayo_code/:alpamayo1_5 代码包(已做 CUDA 清零与离线化适配)backbone/Cosmos-Reason2-8B/:本地重建的 VLM 骨干 config + 处理器assets/:适配取证截图模型权重许可见原仓库 LICENSE;本仓库为昇腾 NPU 适配工程。