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
@@ -15,3 +15,22 @@ pip install onnxscript onnxruntime -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
pip check
|
||||
mkdir -p checkpoints data
|
||||
|
||||
# Pre-download MobileNetV2 weights for offline fine-tuning (optional, skip if backbone=simple)
|
||||
python3 -c "
|
||||
import torch, sys, os
|
||||
hub_dir = torch.hub.get_dir()
|
||||
cache = os.path.join(hub_dir, 'checkpoints', 'mobilenet_v2-b0353104.pth')
|
||||
if os.path.exists(cache):
|
||||
print(f'MobileNetV2 weights already cached: {cache}')
|
||||
sys.exit(0)
|
||||
url = 'https://download.pytorch.org/models/mobilenet_v2-b0353104.pth'
|
||||
try:
|
||||
torch.hub.load_state_dict_from_url(url, model_dir=os.path.join(hub_dir, 'checkpoints'))
|
||||
print('MobileNetV2 weights cached to: ' + cache)
|
||||
except Exception as e:
|
||||
print(f'WARNING: MobileNetV2 weights download failed: {e}')
|
||||
print(' backbone=simple still works; for mobilenet, manually download from:')
|
||||
print(f' {url}')
|
||||
print(f' and place at: {cache}')
|
||||
" || echo "WARNING: MobileNetV2 weight pre-download skipped"
|
||||
Reference in new issue
Block a user