Compare commits

...

2 Commits

2 changed files with 14 additions and 13 deletions

View File

@@ -1334,10 +1334,7 @@ class DiffusionPrior(nn.Module):
# predict noise
if self.predict_x_start or self.predict_v:
pred_noise = self.noise_scheduler.predict_noise_from_start(image_embed, t = time_cond, x0 = x_start)
else:
pred_noise = pred
pred_noise = self.noise_scheduler.predict_noise_from_start(image_embed, t = time_cond, x0 = x_start)
if time_next < 0:
image_embed = x_start
@@ -2730,11 +2727,16 @@ class Decoder(nn.Module):
if exists(unet_number):
unet = self.get_unet(unet_number)
# devices
cuda, cpu = torch.device('cuda'), torch.device('cpu')
self.cuda()
devices = [module_device(unet) for unet in self.unets]
self.unets.cpu()
unet.cuda()
self.unets.to(cpu)
unet.to(cuda)
yield
@@ -2975,10 +2977,7 @@ class Decoder(nn.Module):
# predict noise
if predict_x_start or predict_v:
pred_noise = noise_scheduler.predict_noise_from_start(img, t = time_cond, x0 = x_start)
else:
pred_noise = pred
pred_noise = noise_scheduler.predict_noise_from_start(img, t = time_cond, x0 = x_start)
c1 = eta * ((1 - alpha / alpha_next) * (1 - alpha_next) / (1 - alpha)).sqrt()
c2 = ((1 - alpha_next) - torch.square(c1)).sqrt()
@@ -3120,7 +3119,8 @@ class Decoder(nn.Module):
distributed = False,
inpaint_image = None,
inpaint_mask = None,
inpaint_resample_times = 5
inpaint_resample_times = 5,
one_unet_in_gpu_at_time = True
):
assert self.unconditional or exists(image_embed), 'image embed must be present on sampling from decoder unless if trained unconditionally'
@@ -3143,6 +3143,7 @@ class Decoder(nn.Module):
assert image.shape[0] == batch_size, 'image must have batch size of {} if starting at unet number > 1'.format(batch_size)
prev_unet_output_size = self.image_sizes[start_at_unet_number - 2]
img = resize_image_to(image, prev_unet_output_size, nearest = True)
is_cuda = next(self.parameters()).is_cuda
num_unets = self.num_unets
@@ -3152,7 +3153,7 @@ class Decoder(nn.Module):
if unet_number < start_at_unet_number:
continue # It's the easiest way to do it
context = self.one_unet_in_gpu(unet = unet) if is_cuda else null_context()
context = self.one_unet_in_gpu(unet = unet) if is_cuda and one_unet_in_gpu_at_time else null_context()
with context:
# prepare low resolution conditioning for upsamplers

View File

@@ -1 +1 @@
__version__ = '1.12.2'
__version__ = '1.12.4'