Delete process_ckpt.py
Browse files- process_ckpt.py +0 -31
process_ckpt.py
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
import traceback
|
2 |
-
from collections import OrderedDict
|
3 |
-
from time import time as ttime
|
4 |
-
import shutil,os
|
5 |
-
import torch
|
6 |
-
from tools.i18n.i18n import I18nAuto
|
7 |
-
|
8 |
-
i18n = I18nAuto()
|
9 |
-
|
10 |
-
def my_save(fea,path):#####fix issue: torch.save doesn't support chinese path
|
11 |
-
dir=os.path.dirname(path)
|
12 |
-
name=os.path.basename(path)
|
13 |
-
tmp_path="%s.pth"%(ttime())
|
14 |
-
torch.save(fea,tmp_path)
|
15 |
-
shutil.move(tmp_path,"%s/%s"%(dir,name))
|
16 |
-
|
17 |
-
def savee(ckpt, name, epoch, steps, hps):
|
18 |
-
try:
|
19 |
-
opt = OrderedDict()
|
20 |
-
opt["weight"] = {}
|
21 |
-
for key in ckpt.keys():
|
22 |
-
if "enc_q" in key:
|
23 |
-
continue
|
24 |
-
opt["weight"][key] = ckpt[key].half()
|
25 |
-
opt["config"] = hps
|
26 |
-
opt["info"] = "%sepoch_%siteration" % (epoch, steps)
|
27 |
-
# torch.save(opt, "%s/%s.pth" % (hps.save_weight_dir, name))
|
28 |
-
my_save(opt, "%s/%s.pth" % (hps.save_weight_dir, name))
|
29 |
-
return "Success."
|
30 |
-
except:
|
31 |
-
return traceback.format_exc()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|