Skip to content

Nick088Official/Real-ESRGAN_Pytorch

 
 

Repository files navigation

Real-ESRGAN Pytorch

Discord

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.

This is a forked Github Version which also includes inferencing for videos

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

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.

Examples


Low quality image:

Real-ESRGAN result:


Low quality image:

Real-ESRGAN result:


Low quality image:

Real-ESRGAN result:

Usage


Basic Python Local Usage:

Installation
pip install git+https://github.com/Nick088/Real-ESRGAN_Pytorch.git
Inference
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', download=True)

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')

Precompiled:

  1. Click Code and Download as Zip.
  2. Open Run_Inference_UI.bat.
  3. After it installs the dependencies, let it run and do Ctrl+Click on Local URL.
  4. Now either for Image Tab or Video Tab, just upload your input, select the Upscale Model (x2, x4, x8) and Submit!

Online Usage:

Google Colab:

  • No UI Open In Colab
  • WEB UI (WARNING: COULD RISK YOUR COLAB FREE TIER) Open In Colab

Hugging Face Space:

Kaggle:

  1. Download one of the 2 Kaggle Notebooks Files above
  2. Go on https://kaggle.com, be sure you make an account and are phone verified.
  3. Click the '+', then 'Create new notebook'.
  4. Click 'File' and 'Import Notebook'.
  5. Import the kaggle notebook file.

CHANGELOG

Update - June 19th, 2024

Kaggle Notebooks files.

Update - May 3rd, 2024

Updated & Fixed the no ui version and added a kaggle notebook too, everything is fixed now.

Update - May 3rd, 2024

Added web ui precompiled local, kaggle web ui notebook.

Credits:

  • Nick088 (improving and porting)
  • forever-ai (making the pytorch implementation model of Real-ESRGAN)
  • Xinntao
  • Tencent
  • Geeve George (no ui inference video code)
  • daroche (fixing web ui video inference code)

About

PyTorch implementation of Real-ESRGAN model

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 50.8%
  • Jupyter Notebook 44.1%
  • Batchfile 5.1%