fix(actpred): ONNX opset 升级 + NumPy 兼容 + 断点续训 + MobileNetV2 离线弹性
- export_onnx: opset 17→18,dynamic_axes 改 dynamic_shapes 消除弃用警告 - predict: action_stats 改为 torch tensor,消除 NumPy 2.0 __array_wrap__ 警告 - train/pretrain: 每 epoch 保存 last.pt,新增 --resume 断点续训练 - model: MobileNetEncoder 下载失败时回退到已缓存权重 - _set.sh: 安装时预缓存 MobileNetV2 权重,失败给出明确指引 - test: 新增 TestResumeCheckpoint(2 用例),总计 58 测试全绿
This commit is contained in:
1 parent
9fc3542771
commit
d17677bade
9 files changed
+183
-18
No files matched your search
+4
-4
@@ -58,8 +58,8 @@ class ActionPredictorInference:
|
||||
raise ValueError(
|
||||
f"action_stats.npy 形状应为 (2, {self._data_cfg.action_dim}),"
|
||||
f"实际为 {stats.shape},请检查文件: {stats_path}")
|
||||
self._action_mean = stats[0].astype(np.float32)
|
||||
self._action_std = stats[1].astype(np.float32)
|
||||
self._action_mean = torch.from_numpy(stats[0].astype(np.float32)).to(self._device)
|
||||
self._action_std = torch.from_numpy(stats[1].astype(np.float32)).to(self._device)
|
||||
|
||||
@torch.no_grad()
|
||||
def predict(self, images, action_history: np.ndarray) -> np.ndarray:
|
||||
@@ -83,10 +83,10 @@ class ActionPredictorInference:
|
||||
if self._action_mean is not None:
|
||||
history = (history - self._action_mean) / self._action_std
|
||||
history = history.unsqueeze(0).to(self._device)
|
||||
pred = self._model(img_tensor, history).squeeze(0).cpu().numpy()
|
||||
pred = self._model(img_tensor, history).squeeze(0)
|
||||
if self._action_mean is not None:
|
||||
pred = pred * self._action_std + self._action_mean
|
||||
return pred
|
||||
return pred.cpu().numpy()
|
||||
|
||||
|
||||
def parse_action_history(s: str, action_dim: int) -> np.ndarray:
|
||||
|
||||
Reference in new issue
Block a user