Skip to content

boomb0om/Real-ESRGAN-colab

Repository files navigation

Real-ESRGAN-inference

❗️ This repository is outdated ❗️

❗️ Check out ai-forever/Real-ESRGAN for the last version

PyTorch implementation of a Real-ESRGAN model trained on custom dataset. This model shows better results on faces compared to the original version. It is also easier to integrate this model into your projects.

Real-ESRGAN is an upgraded ESRGAN trained with pure synthetic data is capable of enhancing details while removing annoying artifacts for common real-world images.

This is not an official implementation. We partially use code from the original repository

You can try it in google colab Open In Colab

Installation


  1. Clone repo

    git clone https://github.com/boomb0om/Real-ESRGAN-colab
    cd Real-ESRGAN-colab
  2. Install requirements

    pip install -r requirements.txt
  3. Download pretrained weights and put them into weights/ folder

Usage


Basic usage:

import torch
from PIL import Image
import numpy as np
from realesrgan import RealESRGAN

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

model = RealESRGAN(device, scale=4)
model.load_weights('weights/RealESRGAN_x4.pth')

path_to_image = 'inputs/lr_image.png'
image = Image.open(path_to_image).convert('RGB')

sr_image = model.predict(image)

sr_image.save('results/sr_image.png')

Examples


Low quality image:

Real-ESRGAN result:


Low quality image:

Real-ESRGAN result:


Low quality image:

Real-ESRGAN result: