Skip to content

Commit

Permalink
Set default latent scale mode to Latent (nearest-exact)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberbeing committed Jan 29, 2024
1 parent 6d5a2e5 commit 9141166
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ def init(self, all_prompts, all_seeds, all_subseeds):
if tuple(self.hr_negative_prompt) != tuple(self.negative_prompt):
self.extra_generation_params["Hires negative prompt"] = self.hr_negative_prompt

self.latent_scale_mode = shared.latent_upscale_modes.get(self.hr_upscaler, None) if self.hr_upscaler is not None else shared.latent_upscale_modes.get(shared.latent_upscale_default_mode, "nearest")
self.latent_scale_mode = shared.latent_upscale_modes.get(self.hr_upscaler, None) if self.hr_upscaler is not None else shared.latent_upscale_modes.get(shared.latent_upscale_default_mode, "nearest-exact")
if self.enable_hr and self.latent_scale_mode is None:
if not any(x.name == self.hr_upscaler for x in shared.sd_upscalers):
raise Exception(f"could not find upscaler named {self.hr_upscaler}")
Expand Down Expand Up @@ -1654,7 +1654,7 @@ def init(self, all_prompts, all_seeds, all_subseeds):
devices.torch_gc()

if self.resize_mode == 3:
self.init_latent = torch.nn.functional.interpolate(self.init_latent, size=(self.height // opt_f, self.width // opt_f), mode="bilinear")
self.init_latent = torch.nn.functional.interpolate(self.init_latent, size=(self.height // opt_f, self.width // opt_f), mode="nearest-exact", antialias=False)

if image_mask is not None:
init_mask = latent_mask
Expand Down
2 changes: 1 addition & 1 deletion modules/sd_hijack_unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def cat(self, tensors, *args, **kwargs):
if len(tensors) == 2:
a, b = tensors
if a.shape[-2:] != b.shape[-2:]:
a = torch.nn.functional.interpolate(a, b.shape[-2:], mode="nearest")
a = torch.nn.functional.interpolate(a, b.shape[-2:], mode="nearest-exact")

tensors = (a, b)

Expand Down
2 changes: 1 addition & 1 deletion modules/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

tab_names = []

latent_upscale_default_mode = "Latent"
latent_upscale_default_mode = "Latent (nearest-exact)"
latent_upscale_modes = {
"Latent": {"mode": "bilinear", "antialias": False},
"Latent (antialiased)": {"mode": "bilinear", "antialias": True},
Expand Down

0 comments on commit 9141166

Please sign in to comment.