forked from elvisyjlin/AttGAN-PyTorch
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
20 lines (16 loc) · 652 Bytes
/
utils.py
File metadata and controls
20 lines (16 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Copyright (C) 2019 Elvis Yu-Jing Lin <elvisyjlin@gmail.com>
#
# This work is licensed under the MIT License. To view a copy of this license,
# visit https://opensource.org/licenses/MIT.
"""Helper functions"""
import os
from glob import glob
def find_model(path, epoch='latest'):
if epoch == 'latest':
files = glob(os.path.join(path, '*.pth'))
file = sorted(files, key=lambda x: int(x.rsplit('.', 2)[1]))[-1]
else:
file = os.path.join(path, 'weights.{:d}.pth'.format(int(epoch)))
assert os.path.exists(file), 'File not found: ' + file
print('Find model of {} epoch: {}'.format(epoch, file))
return file