Browse Source

Bug fix

tags/v1.2.5
deeppppp 8 months ago
parent
commit
770dff4b04
2 changed files with 10 additions and 6 deletions
  1. 2
    1
      argv/checkpoints.py
  2. 8
    5
      checkpoints.py

+ 2
- 1
argv/checkpoints.py View File

@@ -47,7 +47,7 @@ def check_arg_checkpoints(parser, args):
Conf.log.debug(args.checkpoints)
if not ('download' in str(args.func)):
for _, v in args.checkpoints.items():
if not os.path.isfile(v):
if (_ != 'checkpoints_path' and not os.path.isfile(v)):
parser.error(
"Checkpoints file not found! "
"You can download them using : {} checkpoints download".format(sys.argv[0])
@@ -60,6 +60,7 @@ def set_arg_checkpoints(args):
'correct_to_mask': os.path.join(str(args.checkpoints), "cm.lib"),
'maskref_to_maskdet': os.path.join(str(args.checkpoints), "mm.lib"),
'maskfin_to_nude': os.path.join(str(args.checkpoints), "mn.lib"),
'checkpoints_path': str(args.checkpoints),
}



+ 8
- 5
checkpoints.py View File

@@ -38,17 +38,20 @@ def download(_):
try:
Conf.log.info("Downloading {}".format(cdn_url))
dl_file(Conf.checkpoints_cdn.format(Conf.checkpoints_version), temp_zip)
if not os.path.exists(Conf.args['checkpoints']['checkpoints_path']):
os.mkdir(Conf.args['checkpoints']['checkpoints_path'])

Conf.log.info("Extracting {}".format(temp_zip))
unzip(temp_zip, Conf.args['checkpoints'])
unzip(temp_zip, Conf.args['checkpoints']['checkpoints_path'])

Conf.log.info("Moving Checkpoints To Final Location")

for c in ("cm.lib", "mm.lib", "mn.lib"):
if os.path.isfile(os.path.join(Conf.args['checkpoints'], c)):
os.remove(os.path.join(Conf.args['checkpoints'], c))
shutil.move(os.path.join(Conf.args['checkpoints'], 'checkpoints', c), Conf.args['checkpoints'])
shutil.rmtree(os.path.join(Conf.args['checkpoints'], 'checkpoints'))
if os.path.isfile(os.path.join(Conf.args['checkpoints']['checkpoints_path'], c)):
os.remove(os.path.join(Conf.args['checkpoints']['checkpoints_path'], c))
shutil.move(os.path.join(Conf.args['checkpoints']['checkpoints_path'], 'checkpoints', c), Conf.args['checkpoints']['checkpoints_path'])
shutil.rmtree(os.path.join(Conf.args['checkpoints']['checkpoints_path'], 'checkpoints'))

except Exception as e:
Conf.log.error(e)

Loading…
Cancel
Save