Skip to content

ashleykleynhans/runpod-worker-real-esrgan

Repository files navigation

Real-ESRGAN | RunPod Serverless Worker

The is the source code for a RunPod Serverless worker that uses Real-ESRGAN for Restoration/Upscaling.

Model

The following models are available by default:

  • RealESRGAN_x2plus
  • RealESRGAN_x4plus
  • RealESRNet_x4plus
  • RealESRGAN_x4plus_anime_6B

Testing

  1. Local Testing
  2. RunPod Testing

Building the Docker image that will be used by the Serverless Worker

There are two options:

  1. Network Volume
  2. Standalone (without Network Volume)

API

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
  }
}

Serverless Handler

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"
  }
}

Acknowledgements

Community and Contributing

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.

Discord Banner 2

Appreciate my work?

Buy Me A Coffee