Compare commits

...
1 Commits
Author SHA1 Message Date
Phil Wang 5ad56dda25 save samples and models to ./results path 2020-10-09 21:39:46 -07:00
2 changed files with 7 additions and 4 deletions
@@ -28,6 +28,9 @@ SAVE_AND_SAMPLE_EVERY = 1000
UPDATE_EMA_EVERY = 10 UPDATE_EMA_EVERY = 10
EXTS = ['jpg', 'jpeg', 'png'] EXTS = ['jpg', 'jpeg', 'png']
RESULTS_FOLDER = Path('./results')
RESULTS_FOLDER.mkdir(exist_ok = True)
# helpers functions # helpers functions
def exists(x): def exists(x):
@@ -497,10 +500,10 @@ class Trainer(object):
'model': self.model.state_dict(), 'model': self.model.state_dict(),
'ema': self.ema_model.state_dict() 'ema': self.ema_model.state_dict()
} }
torch.save(data, f'./model-{milestone}.pt') torch.save(data, str(RESULTS_FOLDER / f'model-{milestone}.pt'))
def load(self, milestone): def load(self, milestone):
data = torch.load(f'./model-{milestone}.pt') data = torch.load(str(RESULTS_FOLDER / 'model-{milestone}.pt'))
self.step = data['step'] self.step = data['step']
self.model.load_state_dict(data['model']) self.model.load_state_dict(data['model'])
@@ -527,7 +530,7 @@ class Trainer(object):
batches = num_to_groups(36, self.batch_size) batches = num_to_groups(36, self.batch_size)
all_images_list = list(map(lambda n: self.ema_model.sample(self.image_size, batch_size=n), batches)) all_images_list = list(map(lambda n: self.ema_model.sample(self.image_size, batch_size=n), batches))
all_images = torch.cat(all_images_list, dim=0) all_images = torch.cat(all_images_list, dim=0)
utils.save_image(all_images, f'./sample-{milestone}.png', nrow=6) utils.save_image(all_images, str(RESULTS_FOLDER / 'sample-{milestone}.png'), nrow=6)
self.save(milestone) self.save(milestone)
self.step += 1 self.step += 1
+1 -1
View File
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup( setup(
name = 'denoising-diffusion-pytorch', name = 'denoising-diffusion-pytorch',
packages = find_packages(), packages = find_packages(),
version = '0.5.0', version = '0.5.1',
license='MIT', license='MIT',
description = 'Denoising Diffusion Probabilistic Models - Pytorch', description = 'Denoising Diffusion Probabilistic Models - Pytorch',
author = 'Phil Wang', author = 'Phil Wang',