Skip to content

Commit

Permalink
real-esrgan
Browse files Browse the repository at this point in the history
  • Loading branch information
Moebits committed Oct 11, 2022
1 parent 8779bdc commit 6fc2475
Show file tree
Hide file tree
Showing 31 changed files with 2,867 additions and 26 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added assets/laffey2x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/laffey2x.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "waifu2x",
"version": "1.1.0",
"version": "1.1.1",
"description": "2x upscaling of images with waifu2x",
"main": "dist/waifu2x.js",
"types": "dist/waifu2x.d.ts",
Expand Down
14 changes: 13 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
This package uses the pre-built Windows x64 and macOS arm64 binaries from [**waifu2x-converter-cpp**](https://github.com/DeadSix27/waifu2x-converter-cpp) in order to upscale anime-styled images with node.js. For upscaling videos, you will also need
to have [**ffmpeg**](https://ffmpeg.org/) installed. For a gui version, you can also see my [Waifu2x GUI app](https://github.com/Tenpi/Waifu2x-GUI).

**New** - Added the [**Real-ESRGAN**](https://github.com/xinntao/Real-ESRGAN) upscaler which is faster and gives better results than waifu2x. To use it,
set upscaler to "real-esrgan" in the options. When using Real-ESRGAN, you can only provide scale factors from 2-4 and all other waifu2x specific settings are ignored. At 4x upscale it uses the Anime4x model which is a bit slower, but provides better results, so it is recommended to upscale at 4x when using Real-ESRGAN.

### Insall
```ts
npm install waifu2x
Expand Down Expand Up @@ -40,6 +43,13 @@ let progress = (current: number, total: number) => {
console.log(`Current Image: ${current} Total Images: ${total}`)
if (current === 5) return true
}

/*Percentage progress is Real-ESRGAN only. Return true to stop early.*/
let progress = (percent: number) => {
console.log(`Percent: ${percent}`)
if (percent > 50) return true
}
await waifu2x.upscaleImage("./images/laffey.png", "./images/upscaled/laffey2x.png", {scale: 4, upscaler: "real-esrgan"}, progress)
```

#### Upscaling Gifs / Animated Webps
Expand Down Expand Up @@ -144,6 +154,8 @@ export interface Waifu2xOptions {
limit?: number
parallelFrames?: number
webpPath?: string
upscaler?: string
esrganPath?: string
}
```

Expand Down Expand Up @@ -190,6 +202,6 @@ export interface Waifu2xVideoOptions extends Waifu2xOptions {

`laffey2x.png`

<img src="https://raw.githubusercontent.com/Tenpi/waifu2x/master/assets/laffey2x.png" />
<img src="https://raw.githubusercontent.com/Tenpi/waifu2x/master/assets/laffey2x.jpg" />

</details>
Binary file not shown.
43 changes: 43 additions & 0 deletions real-esrgan/mac/models/realesr-animevideov3-x2.param
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
7767517
41 42
Input input.1 0 1 data
Split splitncnn_input0 1 2 data input.1_splitncnn_0 input.1_splitncnn_1
Convolution Conv_0 1 1 input.1_splitncnn_1 54 0=64 1=3 4=1 5=1 6=1728
PReLU PRelu_1 1 1 54 56 0=64
Convolution Conv_2 1 1 56 57 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_3 1 1 57 59 0=64
Convolution Conv_4 1 1 59 60 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_5 1 1 60 62 0=64
Convolution Conv_6 1 1 62 63 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_7 1 1 63 65 0=64
Convolution Conv_8 1 1 65 66 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_9 1 1 66 68 0=64
Convolution Conv_10 1 1 68 69 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_11 1 1 69 71 0=64
Convolution Conv_12 1 1 71 72 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_13 1 1 72 74 0=64
Convolution Conv_14 1 1 74 75 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_15 1 1 75 77 0=64
Convolution Conv_16 1 1 77 78 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_17 1 1 78 80 0=64
Convolution Conv_18 1 1 80 81 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_19 1 1 81 83 0=64
Convolution Conv_20 1 1 83 84 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_21 1 1 84 86 0=64
Convolution Conv_22 1 1 86 87 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_23 1 1 87 89 0=64
Convolution Conv_24 1 1 89 90 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_25 1 1 90 92 0=64
Convolution Conv_26 1 1 92 93 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_27 1 1 93 95 0=64
Convolution Conv_28 1 1 95 96 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_29 1 1 96 98 0=64
Convolution Conv_30 1 1 98 99 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_31 1 1 99 101 0=64
Convolution Conv_32 1 1 101 102 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_33 1 1 102 104 0=64
Convolution Conv_34 1 1 104 105 0=48 1=3 4=1 5=1 6=27648
PixelShuffle DepthToSpace_35 1 1 105 106 0=4
Interp Resize_37 1 1 input.1_splitncnn_0 111 0=1 1=4.000000e+00 2=4.000000e+00
BinaryOp Add_38 2 1 106 111 112
Interp Resize_40 1 1 112 output 0=3 1=5.000000e-01 2=5.000000e-01
Binary file not shown.
43 changes: 43 additions & 0 deletions real-esrgan/mac/models/realesr-animevideov3-x3.param
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
7767517
41 42
Input input.1 0 1 data
Split splitncnn_input0 1 2 data input.1_splitncnn_0 input.1_splitncnn_1
Convolution Conv_0 1 1 input.1_splitncnn_1 54 0=64 1=3 4=1 5=1 6=1728
PReLU PRelu_1 1 1 54 56 0=64
Convolution Conv_2 1 1 56 57 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_3 1 1 57 59 0=64
Convolution Conv_4 1 1 59 60 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_5 1 1 60 62 0=64
Convolution Conv_6 1 1 62 63 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_7 1 1 63 65 0=64
Convolution Conv_8 1 1 65 66 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_9 1 1 66 68 0=64
Convolution Conv_10 1 1 68 69 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_11 1 1 69 71 0=64
Convolution Conv_12 1 1 71 72 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_13 1 1 72 74 0=64
Convolution Conv_14 1 1 74 75 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_15 1 1 75 77 0=64
Convolution Conv_16 1 1 77 78 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_17 1 1 78 80 0=64
Convolution Conv_18 1 1 80 81 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_19 1 1 81 83 0=64
Convolution Conv_20 1 1 83 84 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_21 1 1 84 86 0=64
Convolution Conv_22 1 1 86 87 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_23 1 1 87 89 0=64
Convolution Conv_24 1 1 89 90 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_25 1 1 90 92 0=64
Convolution Conv_26 1 1 92 93 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_27 1 1 93 95 0=64
Convolution Conv_28 1 1 95 96 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_29 1 1 96 98 0=64
Convolution Conv_30 1 1 98 99 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_31 1 1 99 101 0=64
Convolution Conv_32 1 1 101 102 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_33 1 1 102 104 0=64
Convolution Conv_34 1 1 104 105 0=48 1=3 4=1 5=1 6=27648
PixelShuffle DepthToSpace_35 1 1 105 106 0=4
Interp Resize_37 1 1 input.1_splitncnn_0 111 0=1 1=4.000000e+00 2=4.000000e+00
BinaryOp Add_38 2 1 106 111 112
Interp Resize_40 1 1 112 output 0=3 1=7.500000e-01 2=7.500000e-01
Binary file not shown.
42 changes: 42 additions & 0 deletions real-esrgan/mac/models/realesr-animevideov3-x4.param
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
7767517
40 41
Input input.1 0 1 data
Split splitncnn_input0 1 2 data input.1_splitncnn_0 input.1_splitncnn_1
Convolution Conv_0 1 1 input.1_splitncnn_1 54 0=64 1=3 4=1 5=1 6=1728
PReLU PRelu_1 1 1 54 56 0=64
Convolution Conv_2 1 1 56 57 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_3 1 1 57 59 0=64
Convolution Conv_4 1 1 59 60 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_5 1 1 60 62 0=64
Convolution Conv_6 1 1 62 63 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_7 1 1 63 65 0=64
Convolution Conv_8 1 1 65 66 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_9 1 1 66 68 0=64
Convolution Conv_10 1 1 68 69 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_11 1 1 69 71 0=64
Convolution Conv_12 1 1 71 72 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_13 1 1 72 74 0=64
Convolution Conv_14 1 1 74 75 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_15 1 1 75 77 0=64
Convolution Conv_16 1 1 77 78 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_17 1 1 78 80 0=64
Convolution Conv_18 1 1 80 81 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_19 1 1 81 83 0=64
Convolution Conv_20 1 1 83 84 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_21 1 1 84 86 0=64
Convolution Conv_22 1 1 86 87 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_23 1 1 87 89 0=64
Convolution Conv_24 1 1 89 90 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_25 1 1 90 92 0=64
Convolution Conv_26 1 1 92 93 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_27 1 1 93 95 0=64
Convolution Conv_28 1 1 95 96 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_29 1 1 96 98 0=64
Convolution Conv_30 1 1 98 99 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_31 1 1 99 101 0=64
Convolution Conv_32 1 1 101 102 0=64 1=3 4=1 5=1 6=36864
PReLU PRelu_33 1 1 102 104 0=64
Convolution Conv_34 1 1 104 105 0=48 1=3 4=1 5=1 6=27648
PixelShuffle DepthToSpace_35 1 1 105 106 0=4
Interp Resize_37 1 1 input.1_splitncnn_0 111 0=1 1=4.000000e+00 2=4.000000e+00
BinaryOp Add_38 2 1 106 111 output
Binary file not shown.
Loading

0 comments on commit 6fc2475

Please sign in to comment.