forked from czczup/FAST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.py
More file actions
21 lines (19 loc) · 677 Bytes
/
release.py
File metadata and controls
21 lines (19 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import torch
import mmcv
import argparse
import os.path as osp
parser = argparse.ArgumentParser(description='Hyperparams')
parser.add_argument('checkpoint', nargs='?', type=str, default=None)
args = parser.parse_args()
dir_name = args.checkpoint.split("/")[-2]
checkpoint = torch.load(args.checkpoint, map_location='cpu')
print(checkpoint.keys())
state_dict = checkpoint['ema']
for k, v in state_dict.items():
print(k)
checkpoint = {'ema': state_dict}
mmcv.mkdir_or_exist("converted/")
try:
torch.save(checkpoint, osp.join("converted", dir_name+".pth"), _use_new_zipfile_serialization=False)
except:
torch.save(checkpoint, osp.join("converted", dir_name+".pth"))