Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions ldm/invoke/generator/txt2img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,28 @@ def get_make_image(self,prompt,sampler,steps,cfg_scale,ddim_eta,
"""
uc, c, extra_conditioning_info = conditioning

trained_square = 512 * 512
actual_square = width * height
scale = math.sqrt(trained_square / actual_square)

init_width = math.ceil(scale * width / 64) * 64
init_height = math.ceil(scale * height / 64) * 64

@torch.no_grad()
def make_image(x_T):

scale_dim = min(width, height)
scale = 512 / scale_dim

init_width = math.ceil(scale * width / 64) * 64
init_height = math.ceil(scale * height / 64) * 64

shape = [
self.latent_channels,
init_height // self.downsampling_factor,
init_width // self.downsampling_factor,
]

sampler.make_schedule(
ddim_num_steps=steps, ddim_eta=ddim_eta, verbose=False
)

#x = self.get_noise(init_width, init_height)
x = x_T

if self.free_gpu_mem and self.model.model.device != self.model.device:
self.model.model.to(self.model.device)

Expand All @@ -65,15 +64,15 @@ def make_image(x_T):
img_callback = step_callback,
extra_conditioning_info = extra_conditioning_info
)

print(
f"\n>> Interpolating from {init_width}x{init_height} to {width}x{height} using DDIM sampling"
)

# resizing
samples = torch.nn.functional.interpolate(
samples,
size=(height // self.downsampling_factor, width // self.downsampling_factor),
samples,
size=(height // self.downsampling_factor, width // self.downsampling_factor),
mode="bilinear"
)

Expand Down Expand Up @@ -162,7 +161,7 @@ def get_noise(self,width,height,scale = True):
else:
scaled_width = width
scaled_height = height

device = self.model.device
if self.use_mps_noise or device.type == 'mps':
return torch.randn([1,
Expand Down