The is the source code for a RunPod Serverless worker that uses Real-ESRGAN for Restoration/Upscaling.
The following models are available by default:
- RealESRGAN_x2plus
- RealESRGAN_x4plus
- RealESRNet_x4plus
- RealESRGAN_x4plus_anime_6B
There are two options:
- Network Volume
- Standalone (without Network Volume)
The worker provides an API for inference. The API payload looks like this:
{
"input": {
"source_image": "base64 encoded source image content",
"model": "RealESRGAN_x4plus",
"scale": 2,
"face_enhance": true
}
}
The serverless handler (rp_handler.py
) is a Python script that handles
inference requests. It defines a function handler(event) that takes an
inference request, runs the inference using the Real-ESRGAN model, and
returns the output as a JSON response in the following format:
{
"output": {
"status": "ok",
"image": "base64 encoded output image"
}
}
Pull requests and issues on GitHub are welcome. Bug fixes and new features are encouraged.
You can contact me and get help with deploying your Serverless worker to RunPod on the RunPod Discord Server below, my username is ashleyk.