aboutsummaryrefslogtreecommitdiffstats
path: root/modules/upscaler.py
diff options
context:
space:
mode:
authorBruno Seoane <brunoseoaneamarillo@gmail.com>2022-11-04 19:40:13 +0000
committerBruno Seoane <brunoseoaneamarillo@gmail.com>2022-11-04 19:40:13 +0000
commitfd66f669ea25bad1409aec87ef14b8417009bddc (patch)
tree42348fb16d018920f6d7fc5970f6c54803ba5e72 /modules/upscaler.py
parent31db25ecc8d9c3996e7bac00cc616ee12557b7d3 (diff)
parent89722fb5e4eda2adc5d3a6abf8babf8a58e80d69 (diff)
downloadstable-diffusion-webui-gfx803-fd66f669ea25bad1409aec87ef14b8417009bddc.tar.gz
stable-diffusion-webui-gfx803-fd66f669ea25bad1409aec87ef14b8417009bddc.tar.bz2
stable-diffusion-webui-gfx803-fd66f669ea25bad1409aec87ef14b8417009bddc.zip
Merge branch 'master' of https://github.com/AUTOMATIC1111/stable-diffusion-webui
Diffstat (limited to 'modules/upscaler.py')
-rw-r--r--modules/upscaler.py17
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