Skip to content

Commit 5ad56dd

Browse files
committed
save samples and models to ./results path
1 parent ff451f6 commit 5ad56dd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

denoising_diffusion_pytorch/denoising_diffusion_pytorch.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
UPDATE_EMA_EVERY = 10
2929
EXTS = ['jpg', 'jpeg', 'png']
3030

31+
RESULTS_FOLDER = Path('./results')
32+
RESULTS_FOLDER.mkdir(exist_ok = True)
33+
3134
# helpers functions
3235

3336
def exists(x):
@@ -497,10 +500,10 @@ def save(self, milestone):
497500
'model': self.model.state_dict(),
498501
'ema': self.ema_model.state_dict()
499502
}
500-
torch.save(data, f'./model-{milestone}.pt')
503+
torch.save(data, str(RESULTS_FOLDER / f'model-{milestone}.pt'))
501504

502505
def load(self, milestone):
503-
data = torch.load(f'./model-{milestone}.pt')
506+
data = torch.load(str(RESULTS_FOLDER / 'model-{milestone}.pt'))
504507

505508
self.step = data['step']
506509
self.model.load_state_dict(data['model'])
@@ -527,7 +530,7 @@ def train(self):
527530
batches = num_to_groups(36, self.batch_size)
528531
all_images_list = list(map(lambda n: self.ema_model.sample(self.image_size, batch_size=n), batches))
529532
all_images = torch.cat(all_images_list, dim=0)
530-
utils.save_image(all_images, f'./sample-{milestone}.png', nrow=6)
533+
utils.save_image(all_images, str(RESULTS_FOLDER / 'sample-{milestone}.png'), nrow=6)
531534
self.save(milestone)
532535

533536
self.step += 1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name = 'denoising-diffusion-pytorch',
55
packages = find_packages(),
6-
version = '0.5.0',
6+
version = '0.5.1',
77
license='MIT',
88
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
99
author = 'Phil Wang',

0 commit comments

Comments
 (0)