模型名称: folding_latest 模型链接: https://ai.gitcode.com/hf_mirrors/lerobot/folding_latest 模型描述: LeRobot π₀.₅ (Pi05) Vision-Language-Action 机器人折叠策略模型,基于 PaliGemma 3B 视觉语言模型与 Gemma 300M action expert,输入 3 路相机图像、16 维关节状态与任务文本,输出 16 维动作序列,适用于布料折叠等灵巧操作任务。 模型架构: VLA (Vision-Language-Action),PaliGemma 3B + Gemma 300M action expert + Diffusion 动作生成 参数规模: 3.62B(3616.8M)
本仓库为 folding_latest(Pi0.5 VLA 策略)在昇腾 NPU 上的部署实现,关键适配点:
input_layernorm.dense.weight),必须使用 lerobot 官方指定的 fix/lerobot_openpi 分支(transformers 4.53.3)才能正确加载全部权重(813 keys 完整加载)。transformers.models.siglip.check mock 模块,跳过版本检查(推理本身不依赖)。relative_action_processor.py 兼容实现并在导入时注册,同时配对 preprocessor 的 relative 步骤给 postprocessor 的 absolute 步骤。aclnnLayerNorm EZ1001(输入/权重 dtype 不一致),统一为 bf16 解决。type/use_relative_actions 等 lerobot 0.4.4 不支持的遗留字段,加载时按 PI05Config 合法字段过滤。完整的从零复现步骤(环境、依赖版本坑、权重下载、代码补丁、常见问题)见 REPRODUCE.md。
fix/lerobot_openpi 分支(4.53.3):PI05 的 gemma_expert 权重含 input_layernorm.dense.weight 等 dense/adarms 结构,普通 pip 版 transformers 无法对齐(加载会大量 Missing keys)。inference.py 会自动优先加载 /opt/atomgit/tf_openpi_install 目录;配套 tokenizers 需 0.21.x(<0.22)。google/paligemma-3b-pt-224(gated 仓库无法直接下载),需从 GitCode 镜像 clone 并用 --tokenizer_dir 指定。aclnnLayerNorm EZ1001,脚本已内置 to(dtype=torch.bfloat16) 修复。groot_n1.py 的 GR00TN15Config 补 default=None(详见 REPRODUCE.md 坑 3),否则 make_pre_post_processors 导入失败。| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch / torch_npu | 2.1.0+ | 昇腾NPU推理 |
| transformers | >= 4.45.0 | HuggingFace 库 |
| 昇腾驱动 | CANN 8.0.RC2+ | 推荐最新版 |
安装命令:
pip install torch torch_npu transformers sentencepiece# 检查 NPU 设备
npu-smi info# 单条输入推理
python inference.py --input "测试输入内容" --model_path ./folding_latest
# 批量输入推理
python inference.py --input_file test_samples.txt --model_path ./folding_latest| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --input | str | - | 输入文本/图像路径 |
| --input_file | str | - | 批量输入文件路径 |
| --model_path | str | folding_latest | 模型路径 |
| --max_length | int | 2048 | 最大生成长度 |
输入:
fold the shirt输出:
动作序列形状 (5, 1, 16),首步动作: [0.9795, 0.8474, 0.3059, 5.1778, 2.64, 1.0784, -1.5538, -0.9359, 0.7393, -1.5548, -1.4784, 6.0992, -2.1656, -1.5668, 2.7531, -8.5305]耗时: 1.08s(30 步动作,npu:0)
输入:
fold the towel输出:
动作序列形状 (5, 1, 16),首步动作: [0.9649, 1.2778, 0.963, 5.4601, ...]耗时: 0.65s(30 步动作,npu:0)
输入:
fold a t-shirt输出:
动作序列形状 (5, 1, 16),首步动作: [0.5099, 1.1189, -0.0008, 5.5222, ...]耗时: 0.65s(30 步动作,npu:0)



| 测试样例 | NPU输出 | 耗时 | 是否成功运行 |
|---|---|---|---|
| fold the shirt | 动作序列 (30,1,16),首步 [0.9795, 0.8474, 0.3059, 5.1778, ... | 1.08s | ✅ 成功 |
| fold the towel | 动作序列 (30,1,16),首步 [0.9649, 1.2778, 0.963, 5.4601, ... | 0.65s | ✅ 成功 |
| fold a t-shirt | 动作序列 (30,1,16),首步 [0.5099, 1.1189, -0.0008, 5.5222, ... | 0.66s | ✅ 成功 |
结论: 模型已在 NPU 上成功运行推理,满足验收要求。 说明: 根据最新规则,不再强制精度1%验证,本章节记录 NPU 运行验证结果。
文档生成时间:2026-08-15 23:46:33