ESRGAN Slim
These models are the fastest available ESRGAN models, and are intended to run in a browser.
The model weights were trained using the image-super-resolution
Python repo and subsequently converted to Tensorflow.js models.
Samples + Demo
Here are some examples of upscaled images using these models.
Original | 2x Upscaled | 3x Upscaled | 4x Upscaled |
---|---|---|---|
![]() | ![]() | ![]() | ![]() |
Installation
npm install @upscalerjs/esrgan-slim
Usage
Import a model, specified by its scale:
import Upscaler from 'upscaler';
import x2 from '@upscalerjs/esrgan-slim/2x';
const upscaler = new Upscaler({
model: x2,
})
Available Models
ESRGAN Slim ships with four models corresponding to the desired scale of the upscaled image:
- 2x:
@upscalerjs/esrgan-slim/2x
- 3x:
@upscalerjs/esrgan-slim/3x
- 4x:
@upscalerjs/esrgan-slim/4x
- 8x:
@upscalerjs/esrgan-slim/8x
(note: the 8x model runs only in Node)
All models are also exported via the root export:
import Upscaler from 'upscaler';
import models from '@upscalerjs/esrgan-slim';
const upscaler = new Upscaler({
model: models.x2,
// model: models.x3,
// model: models.x4,
// model: models.x8,
})
Performance + Speed Measurements
Architecture
This model is trained via a Python implementation of the ESRGAN architecture.
- Paper: https://arxiv.org/abs/1809.00219
- Python Repo: https://github.com/idealo/image-super-resolution
The Python repo has instructions on training from scratch if you are so inclined.
Training Details
The model is trained on 4 scales.
The model is trained on the Div2k dataset.
It was trained for 500 epochs, with the following hyperparameters:
- architecture:
rdn
- C:
1
- D:
2
- G:
4
- G0:
64
The batch size was 12, and the batches per epoch was 20. The learning rate was set to 0.0004
. The HR patch size was set to 128
or 129
depending on the scale (ensuring it is divisible by the scale) with the LR patch size being the resultant scale HR_patch_size / scale
.