diff options
author | random-thoughtss <116161560+random-thoughtss@users.noreply.github.com> | 2022-11-03 22:55:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 22:55:54 +0000 |
commit | 243253ff4a8ae944ba142abe9c1e78a92dd14ebe (patch) | |
tree | c40402e18a29ca9a9b167a2f9e47dab39dce0943 /modules/upscaler.py | |
parent | d9e4e4d7a09d4aee8ce249a3c8e91ce165b10fa5 (diff) | |
parent | 20a860b525cb7a319a42994f75a94bbca9a54d89 (diff) | |
download | stable-diffusion-webui-gfx803-243253ff4a8ae944ba142abe9c1e78a92dd14ebe.tar.gz stable-diffusion-webui-gfx803-243253ff4a8ae944ba142abe9c1e78a92dd14ebe.tar.bz2 stable-diffusion-webui-gfx803-243253ff4a8ae944ba142abe9c1e78a92dd14ebe.zip |
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'modules/upscaler.py')
-rw-r--r-- | modules/upscaler.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/modules/upscaler.py b/modules/upscaler.py index 6ab2fb40..83fde7ca 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -10,6 +10,7 @@ import modules.shared from modules import modelloader, shared LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS) +NEAREST = (Image.Resampling.NEAREST if hasattr(Image, 'Resampling') else Image.NEAREST) from modules.paths import models_path @@ -57,7 +58,7 @@ class Upscaler: dest_w = img.width * scale dest_h = img.height * scale for i in range(3): - if img.width >= dest_w and img.height >= dest_h: + if img.width > dest_w and img.height > dest_h: break img = self.do_upscale(img, selected_model) if img.width != dest_w or img.height != dest_h: @@ -120,3 +121,17 @@ class UpscalerLanczos(Upscaler): self.name = "Lanczos" self.scalers = [UpscalerData("Lanczos", None, self)] + +class UpscalerNearest(Upscaler): + scalers = [] + + def do_upscale(self, img, selected_model=None): + return img.resize((int(img.width * self.scale), int(img.height * self.scale)), resample=NEAREST) + + def load_model(self, _): + pass + + def __init__(self, dirname=None): + super().__init__(False) + self.name = "Nearest" + self.scalers = [UpscalerData("Nearest", None, self)]
\ No newline at end of file |