Skip to content

Commit

Permalink
handle checkpoint does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Jan 16, 2021
1 parent dd235e8 commit 8b1e707
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lightweight_gan/lightweight_gan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,8 +1353,10 @@ def load(self, num=-1, print_version=True):
name = num
if num == -1:
checkpoints = self.get_checkpoints()
name = checkpoints[-1]
print(f'continuing from previous epoch - {name}')

if exists(checkpoints):
name = checkpoints[-1]
print(f'continuing from previous epoch - {name}')

self.steps = name * self.save_every

Expand All @@ -1379,6 +1381,6 @@ def get_checkpoints(self):
saved_nums = sorted(map(lambda x: int(x.stem.split('_')[1]), file_paths))

if len(saved_nums) == 0:
return
return None

return saved_nums
2 changes: 1 addition & 1 deletion lightweight_gan/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.17.2'
__version__ = '0.17.3'

0 comments on commit 8b1e707

Please sign in to comment.