Author SHA1 Message Date
ssit 23b7ea3c4b Fix typo 2025-05-27 11:05:05 -04:00
ssit 79a7015453 Bypass conversion of image before upscale model 2025-05-26 23:24:13 -04:00
3 changed files with 8 additions and 11 deletions
+1
View File
@@ -22,3 +22,4 @@ actual_upscaler = None
# Batch of images to upscale
batch = None
batch_as_tensor = None
+4 -9
View File
@@ -9,18 +9,13 @@ if (not hasattr(Image, 'Resampling')): # For older versions of Pillow
class Upscaler:
def _upscale(self, img: Image, scale):
def upscale(self, img: Image, scale, selected_model: str = None):
if scale == 1.0:
return img
if (shared.actual_upscaler is None):
return img.resize((img.width * scale, img.height * scale), Image.Resampling.NEAREST)
tensor = pil_to_tensor(img)
image_upscale_node = ImageUpscaleWithModel()
(upscaled,) = image_upscale_node.upscale(shared.actual_upscaler, tensor.contiguous()) # Tensor may not be contiguous on Mac
return tensor_to_pil(upscaled)
def upscale(self, img: Image, scale, selected_model: str = None):
shared.batch = [self._upscale(img, scale) for img in shared.batch]
return img.resize((img.width * scale, img.height * scale), Image.Resampling.LANCZOS)
(upscaled, ) = ImageUpscaleWithModel().upscale(shared.actual_upscaler, shared.batch_as_tensor)
shared.batch = [tensor_to_pil(upscaled, i) for i in range(len(upscaled))]
return shared.batch[0]
+3 -2
View File
@@ -130,11 +130,12 @@ class UltimateSDUpscale:
shared.actual_upscaler = upscale_model
# Set the batch of images
shared.batch = [tensor_to_pil(image, i) for i in range(len(image))]
shared.batch = [tensor_to_pil(image, 0)] # Script only works with one image, we will do the batch processing ourselves
shared.batch_as_tensor = image
# Processing
sdprocessing = StableDiffusionProcessing(
tensor_to_pil(image), model, positive, negative, vae,
shared.batch[0], model, positive, negative, vae,
seed, steps, cfg, sampler_name, scheduler, denoise, upscale_by, force_uniform_tiles, tiled_decode,
tile_width, tile_height, MODES[self.mode_type], SEAM_FIX_MODES[self.seam_fix_mode],
custom_sampler, custom_sigmas,