Compare commits

..
1 Commits
Author SHA1 Message Date
Phil Wang f2765c4614 update with new and improved cosine noise scheduler 2020-10-09 17:32:18 -07:00
4 changed files with 5 additions and 8 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ model = Unet(
diffusion = GaussianDiffusion(
model,
timesteps = 1000, # number of steps
loss_type = 'l1' # L1 or L2
loss_type = 'l1' # L1 or L2
)
training_images = torch.randn(8, 3, 128, 128)
@@ -28,9 +28,6 @@ SAVE_AND_SAMPLE_EVERY = 1000
UPDATE_EMA_EVERY = 10
EXTS = ['jpg', 'jpeg', 'png']
RESULTS_FOLDER = Path('./results')
RESULTS_FOLDER.mkdir(exist_ok = True)
# helpers functions
def exists(x):
@@ -500,10 +497,10 @@ class Trainer(object):
'model': self.model.state_dict(),
'ema': self.ema_model.state_dict()
}
torch.save(data, str(RESULTS_FOLDER / f'model-{milestone}.pt'))
torch.save(data, f'./model-{milestone}.pt')
def load(self, milestone):
data = torch.load(str(RESULTS_FOLDER / f'model-{milestone}.pt'))
data = torch.load(f'./model-{milestone}.pt')
self.step = data['step']
self.model.load_state_dict(data['model'])
@@ -530,7 +527,7 @@ class Trainer(object):
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 = torch.cat(all_images_list, dim=0)
utils.save_image(all_images, str(RESULTS_FOLDER / f'sample-{milestone}.png'), nrow=6)
utils.save_image(all_images, f'./sample-{milestone}.png', nrow=6)
self.save(milestone)
self.step += 1
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

+1 -1
View File
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name = 'denoising-diffusion-pytorch',
packages = find_packages(),
version = '0.5.2',
version = '0.5.0',
license='MIT',
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
author = 'Phil Wang',