sldl.image

Module contents

class ImageSR(model_name: str = 'SwinIR-M', precision: str = 'full')[source]

Bases: Module

Image Super-Resolution

Takes an image and increases its resoulution by some factor. Currently supports SwinIR, BSRGAN and RealESRGAN models.

Parameters:
  • model_name (str) – Name of the pre-trained model. Can be one of the SwinIR-M, SwinIR-L, BSRGAN, BSRGANx2, and RealESRGAN. Default: SwinIR-M.

  • precision (str) – Can be either full (uses fp32) and half (uses fp16). Default: full.

Example:

from PIL import Image
from sldl.image import ImageSR

sr = ImageSR('BSRGAN')
img = Image.open('test.png')
upscaled = sr(img)
training: bool
property device: device
__call__(img: Image, device: device | None = None) Image[source]

Applies the model.

Parameters:

img (PIL.Image.Image) – An input image.

Returns:

An upscaled version of the input image

Return type:

PIL.Image.Image

class ImageDenoising(model_name: str = 'SwinIR', noise: int = 15, precision: str = 'full')[source]

Bases: Module

Image Denoising

Takes an image and removes the noise from it. Currently supports SwinIR only.

Parameters:
  • model_name (str) – Name of the pre-trained model. Now it can only be SwinIR.

  • noise (int) – Noise level that the model was trained on. Can be of of 15, 25, 50.

  • precision (str.) – Can be either full (uses fp32) and half (uses fp16). Default: full.

Example:

from PIL import Image
from sldl.image import ImageDenoising

denoiser = ImageDenoising('SwinIR')
img = Image.open('test.png')
denoised = denoiser(img)
property device: device
__call__(img: Image) Image[source]

Applies the denoiser.

Parameters:

img (PIL.Image.Image) – An input image.

Returns:

Denoised image.

Return type:

PIL.Image.Image

training: bool