ESRGAN Medium
These models strike a balance between latency and image quality. They aim to be in the middle of speed and performance measurements between @upscalerjs/esrgan-slim
and @upscalerjs/esrgan-thick
.
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-medium
Usage
Import a model, specified by its scale:
import Upscaler from 'upscaler';
import x2 from '@upscalerjs/esrgan-medium/2x';
const upscaler = new Upscaler({
model: x2,
})
Available Models
ESRGAN Medium ships with four models corresponding to the desired scale of the upscaled image:
- 2x:
@upscalerjs/esrgan-medium/2x
- 3x:
@upscalerjs/esrgan-medium/3x
- 4x:
@upscalerjs/esrgan-medium/4x
- 8x:
@upscalerjs/esrgan-medium/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-medium';
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:
10
- G:
64
- 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
.