Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ldm/invoke/restoration/realesrgan.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ def process(self, image, strength: float, seed: str = None, upsampler_scale: int
print(
f'>> Real-ESRGAN Upscaling seed:{seed} : scale:{upsampler_scale}x'
)

# REALSRGAN expects a BGR np array; make array and flip channels
bgr_image_array = np.array(image, dtype=np.uint8)[...,::-1]

output, _ = upsampler.enhance(
np.array(image, dtype=np.uint8),
bgr_image_array,
outscale=upsampler_scale,
alpha_upsampler='realesrgan',
)

res = Image.fromarray(output)
# Flip the channels back to RGB
res = Image.fromarray(output[...,::-1])

if strength < 1.0:
# Resize the image to the new image if the sizes have changed
Expand Down