Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function to show progress #47

Merged
merged 5 commits into from
Jan 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor checkpoints search function
  • Loading branch information
Dok11 committed Jan 16, 2021
commit be04b2191e975f382708ce0e9f62502607ebd860
16 changes: 11 additions & 5 deletions lightweight_gan/lightweight_gan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,11 +1254,8 @@ def load(self, num = -1):

name = num
if num == -1:
file_paths = [p for p in Path(self.models_dir / self.name).glob('model_*.pt')]
saved_nums = sorted(map(lambda x: int(x.stem.split('_')[1]), file_paths))
if len(saved_nums) == 0:
return
name = saved_nums[-1]
checkpoints = self.get_checkpoints()
name = checkpoints[-1]
print(f'continuing from previous epoch - {name}')

self.steps = name * self.save_every
Expand All @@ -1278,3 +1275,12 @@ def load(self, num = -1):
self.G_scaler.load_state_dict(load_data['G_scaler'])
if 'D_scaler' in load_data:
self.D_scaler.load_state_dict(load_data['D_scaler'])

def get_checkpoints(self):
file_paths = [p for p in Path(self.models_dir / self.name).glob('model_*.pt')]
saved_nums = sorted(map(lambda x: int(x.stem.split('_')[1]), file_paths))

if len(saved_nums) == 0:
return

return saved_nums