Skip to main content

ESRGAN Legacy

ESRGAN Legacy is a package of Tensorflow.js models for upscaling images with UpscalerJS.

This package contains the five models available in pre-1.0.0 versions of UpscalerJS.

The model weights include pretrained weights provided via the image-super-resolution Python repo, along with a number of custom trained models.

(ESRGAN Legacy will not see future updates. If possible, switch to one of the other available model packages.)

Samples + Demo

Here are some examples of upscaled images using these models.

Originalpsnr-small Upscaledgans Upscaleddiv2k/2x Upscaleddiv2k/3x Upscaleddiv2k/4x Upscaled
Original imageUpscaled image using esrgan-legacy/psnr-smallUpscaled image using esrgan-legacy/gansUpscaled image using esrgan-legacy/div2k/2xUpscaled image using esrgan-legacy/div2k/3xUpscaled image using esrgan-legacy/div2k/4x

Installation

npm install @upscalerjs/esrgan-legacy

Usage

Import a model:

import Upscaler from 'upscaler';
import gans from '@upscalerjs/esrgan-legacy/gans';

const upscaler = new Upscaler({
model: gans,
})

Available Models

ESRGAN Legacy ships with five models:

  • GANS: @upscalerjs/esrgan-legacy/gans
  • psnr-small: @upscalerjs/esrgan-legacy/psnr-small
  • div2k/2x: @upscalerjs/esrgan-legacy/div2k/2x
  • div2k/3x: @upscalerjs/esrgan-legacy/div2k/3x
  • div2k/4x: @upscalerjs/esrgan-legacy/div2k/4x

All models are also exported via the root export:

import Upscaler from 'upscaler';
import models from '@upscalerjs/esrgan-legacy';

const upscaler = new Upscaler({
model: models.GANS,
// model: models.PSNRSmall,
// model: models.div2K2x,
// model: models.div2K3x,
// model: models.div2K4x,
})

GANS

The gans model uses the pretrained gans weights made available via the original Python repo.

PSNR Small

The psnr-small model uses the pretrained psnr-small weights made available via the original Python repo.

Div2k Models

There are three Div2K models available in 2x, 3x, and 4x scales.

These models were an initial attempt at training from scratch on the Div2K dataset. They've been surpassed in performance and speed by the other available models, and should be avoided if possible.

Performance + Speed Measurements

Architecture

This model is trained via a Python implementation of the ESRGAN architecture.

The Python repo has instructions on training from scratch if you are so inclined.

License

MIT License © Kevin Scott