Skip to content

Super Resolution

Image title

Original image and upscaled image

Warning

Upscaling takes very long time (approximately 45 seconds per image).

BiWAKO.RealESRGAN

Super Resolution model.

Attributes:

Name Type Description
model_path str

Path to the model. If automatic download is enabled, it will be downloaded to this path.

session rt.InferenceSession

ONNX Runtime session.

w, h (int

Width and height of the model input.

input_name str

Name of the input node.

output_name str

Name of the output node.

__init__(self, model='super_resolution4864') special

Initialize RealESRGAN.

Parameters:

Name Type Description Default
model str

Model name or path to the downloaded onnx file. If model has not been downloaded, it will be downloaded automatically. Currently supports ["super_resolution4864", "super_resolution6464"].

'super_resolution4864'

predict(self, image)

Return the upscaled image.

Parameters:

Name Type Description Default
image Image

Image to be upscaled. Accept path or cv2 image.

required

Returns:

Type Description
np.ndarray

Upscaled image in cv2 format.

render(self, prediction, image)

Return the upscaled image. This is just a placeholder.

Parameters:

Name Type Description Default
prediction np.ndarray

Upscaled image in cv2 format. This image is returned.

required
image Image

Original image. Not used.

required

Returns:

Type Description
np.ndarray

Upscaled image in cv2 format.