mirror of
https://github.com/wassname/denoising-diffusion-pytorch.git
synced 2026-09-10 12:01:08 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfbafee555 | ||
|
|
40dd8ba1de | ||
|
|
2ac3f94a80 | ||
|
|
98f2eeac35 | ||
|
|
6e8a0f2082 | ||
|
|
8c36559295 | ||
|
|
f74f536339 | ||
|
|
d85b8bbe2e | ||
|
|
e0a1bed31a | ||
|
|
82b67fc00a | ||
|
|
7c0cd05c27 |
@@ -8,6 +8,8 @@ This implementation was transcribed from the official Tensorflow version <a href
|
|||||||
|
|
||||||
Youtube AI Educators - <a href="https://www.youtube.com/watch?v=W-O7AZNzbzQ">Yannic Kilcher</a> | <a href="https://www.youtube.com/watch?v=344w5h24-h8">AI Coffeebreak with Letitia</a> | <a href="https://www.youtube.com/watch?v=HoKDTa5jHvg">Outlier</a>
|
Youtube AI Educators - <a href="https://www.youtube.com/watch?v=W-O7AZNzbzQ">Yannic Kilcher</a> | <a href="https://www.youtube.com/watch?v=344w5h24-h8">AI Coffeebreak with Letitia</a> | <a href="https://www.youtube.com/watch?v=HoKDTa5jHvg">Outlier</a>
|
||||||
|
|
||||||
|
<a href="https://github.com/yiyixuxu/denoising-diffusion-flax">Flax implementation</a> from <a href="https://github.com/yiyixuxu">YiYi Xu</a>
|
||||||
|
|
||||||
<a href="https://huggingface.co/blog/annotated-diffusion">Annotated code</a> by Research Scientists / Engineers from <a href="https://huggingface.co/">🤗 Huggingface</a>
|
<a href="https://huggingface.co/blog/annotated-diffusion">Annotated code</a> by Research Scientists / Engineers from <a href="https://huggingface.co/">🤗 Huggingface</a>
|
||||||
|
|
||||||
Update: Turns out none of the technicalities really matters at all | <a href="https://arxiv.org/abs/2208.09392">"Cold Diffusion" paper</a>
|
Update: Turns out none of the technicalities really matters at all | <a href="https://arxiv.org/abs/2208.09392">"Cold Diffusion" paper</a>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ def num_to_groups(num, divisor):
|
|||||||
arr.append(remainder)
|
arr.append(remainder)
|
||||||
return arr
|
return arr
|
||||||
|
|
||||||
def convert_image_to(img_type, image):
|
def convert_image_to_fn(img_type, image):
|
||||||
if image.mode != img_type:
|
if image.mode != img_type:
|
||||||
return image.convert(img_type)
|
return image.convert(img_type)
|
||||||
return image
|
return image
|
||||||
@@ -450,7 +450,7 @@ class GaussianDiffusion(nn.Module):
|
|||||||
raise ValueError(f'unknown beta schedule {beta_schedule}')
|
raise ValueError(f'unknown beta schedule {beta_schedule}')
|
||||||
|
|
||||||
alphas = 1. - betas
|
alphas = 1. - betas
|
||||||
alphas_cumprod = torch.cumprod(alphas, axis=0)
|
alphas_cumprod = torch.cumprod(alphas, dim=0)
|
||||||
alphas_cumprod_prev = F.pad(alphas_cumprod[:-1], (1, 0), value = 1.)
|
alphas_cumprod_prev = F.pad(alphas_cumprod[:-1], (1, 0), value = 1.)
|
||||||
|
|
||||||
timesteps, = betas.shape
|
timesteps, = betas.shape
|
||||||
@@ -704,7 +704,7 @@ class Dataset(Dataset):
|
|||||||
self.image_size = image_size
|
self.image_size = image_size
|
||||||
self.paths = [p for ext in exts for p in Path(f'{folder}').glob(f'**/*.{ext}')]
|
self.paths = [p for ext in exts for p in Path(f'{folder}').glob(f'**/*.{ext}')]
|
||||||
|
|
||||||
maybe_convert_fn = partial(convert_image_to, convert_image_to) if exists(convert_image_to) else nn.Identity()
|
maybe_convert_fn = partial(convert_image_to_fn, convert_image_to) if exists(convert_image_to) else nn.Identity()
|
||||||
|
|
||||||
self.transform = T.Compose([
|
self.transform = T.Compose([
|
||||||
T.Lambda(maybe_convert_fn),
|
T.Lambda(maybe_convert_fn),
|
||||||
@@ -810,7 +810,10 @@ class Trainer(object):
|
|||||||
torch.save(data, str(self.results_folder / f'model-{milestone}.pt'))
|
torch.save(data, str(self.results_folder / f'model-{milestone}.pt'))
|
||||||
|
|
||||||
def load(self, milestone):
|
def load(self, milestone):
|
||||||
data = torch.load(str(self.results_folder / f'model-{milestone}.pt'))
|
accelerator = self.accelerator
|
||||||
|
device = accelerator.device
|
||||||
|
|
||||||
|
data = torch.load(str(self.results_folder / f'model-{milestone}.pt'), map_location=device)
|
||||||
|
|
||||||
model = self.accelerator.unwrap_model(self.model)
|
model = self.accelerator.unwrap_model(self.model)
|
||||||
model.load_state_dict(data['model'])
|
model.load_state_dict(data['model'])
|
||||||
@@ -842,6 +845,7 @@ class Trainer(object):
|
|||||||
|
|
||||||
self.accelerator.backward(loss)
|
self.accelerator.backward(loss)
|
||||||
|
|
||||||
|
accelerator.clip_grad_norm_(self.model.parameters(), 1.0)
|
||||||
pbar.set_description(f'loss: {total_loss:.4f}')
|
pbar.set_description(f'loss: {total_loss:.4f}')
|
||||||
|
|
||||||
accelerator.wait_for_everyone()
|
accelerator.wait_for_everyone()
|
||||||
|
|||||||
@@ -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.27.8',
|
version = '0.27.12',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
|
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
|
||||||
author = 'Phil Wang',
|
author = 'Phil Wang',
|
||||||
|
|||||||
Reference in New Issue
Block a user