Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23b7ea3c4b | ||
|
|
79a7015453 |
@@ -22,3 +22,4 @@ actual_upscaler = None
|
||||
|
||||
# Batch of images to upscale
|
||||
batch = None
|
||||
batch_as_tensor = None
|
||||
|
||||
+4
-9
@@ -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]
|
||||
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user