Skip to content

Commit aa5479e

Browse files
committed
修改模型放大倍数识别方式并添加扩展模型的相关说明
[skip ci]
1 parent 2bb85f6 commit aa5479e

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

README.en-US.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Quick Start:
3838
* The artifacts in GitHub Actions are built based on the latest commits. They don't contain Real-ESRGAN-ncnn-vulkan's executable file and models either.
3939
* Use Python 3.10 or above if you want to run Real-ESRGAN GUI from source. Don't forget to install the dependcies by `pip install -r requirements.txt` and extract Real-ESRGAN-ncnn-vulkan to the repository before running `python main.py`.
4040
* It may be possible to run Real-ESRGAN GUI in other Linux distributions, but I have not tested it.
41+
* You can also download more [additional models](#addition-models) and place the `bin` and `param` files in the `models` directory.
4142

4243
</details>
4344

@@ -59,6 +60,11 @@ sh Build-macOS-arm64.sh
5960

6061
> ⚠️ Since I don't have any device running macOS, I may not be able to handle macOS-related issues.
6162
63+
### Related projects
64+
65+
* Use Real-ESRGAN on Android: [tumuyan/RealSR-NCNN-Android](https://github.com/tumuyan/RealSR-NCNN-Android)
66+
* Upscale video with Real-ESRGAN and Vapoursynth: [HolyWu/vs-realesrgan](https://github.com/HolyWu/vs-realesrgan)
67+
6268
## Features
6369

6470
In addition to the features supported by Real-ESRGAN-ncnn-vulkan, Real-ESRGAN GUI also supports these additional features:
@@ -114,7 +120,7 @@ I recommend `realesrgan-x4plus` for real-life photos and `realesrgan-x4plus-anim
114120

115121
For different upscale ratio versions of the same model, it is recommended to choose the version that is equal to or greater than the ratio at which you want to enlarge the image. For example, if a model has x2 and x4 version and you want to upscale an image by 3x, you should choose the x4 version.
116122

117-
Models with `animevideo` in the filename are designed for anime videos. These models are small and have a faster processing speed (about 1.5-3x compare to `realesrgan-x4plus-anime`). However, I recommend [VapourSynth](https://www.vapoursynth.com/) and its [Real-ESRGAN plugin](https://github.com/HolyWu/vs-realesrgan) if you want to upscale an video. Real-ESRGAN GUI will not consider adding video processing related features.
123+
Models with `animevideo` in the filename are designed for anime videos. These models are small and have a faster processing speed (about 1.5-3x compare to `realesrgan-x4plus-anime`). However, Real-ESRGAN GUI will not consider adding video processing related features.
118124

119125
### The usage of tile size
120126

@@ -159,6 +165,14 @@ If this option is not turned on, lossless compression is used when the output is
159165

160166
The configuration will be saved automatically when exiting the program.
161167

168+
### Additional models
169+
170+
You can download additional models from [Upscale Wiki](https://upscale.wiki/wiki/Model_Database) and use them in Real-ESRGAN GUI. These model may produce better (or worse) results than the official model for some images.
171+
172+
These model uses PyTorch's `pth` format, but Real-ESRGAN GUI (Real-ESRGAN-ncnn-vulkan) needs NCNN's `bin` and `param` format. You can follow this [guide](https://note.youdao.com/ynoteshare/?id=2b001cd4175ab46d2ce11ecb5a6d84ff) (written by RealSR-NCNN-Android's author in Chinese) to make a conversion with [cupscale](https://github.com/n00mkrad/cupscale)'s `pth2ncnn` utility. The model's filename must contain its upscale factor like `x4` or `4x`.
173+
174+
You can download some converted additional models from [here](https://github.com/TransparentLC/realesrgan-gui/releases/tag/additional-models).
175+
162176
## Open-source libraries used
163177

164178
* [Pillow](https://github.com/python-pillow/Pillow)

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434

3535
<summary>其它的运行方式和说明</summary>
3636

37-
* Release 中的 `realesrgan-gui-windows.7z``realesrgan-gui-ubuntu.tar.xz` 不包含 Real-ESRGAN-ncnn-vulkan 的主程序和模型,请自行在[这里](https://github.com/xinntao/Real-ESRGAN/releases)下载后解压到 GUI 的主程序所在的目录。
38-
* Actions 中上传的是根据最新提交的代码打包的版本(相当于 Nightly),同样不包含 Real-ESRGAN-ncnn-vulkan 的主程序和模型
37+
* Release 中的 `realesrgan-gui-windows.7z``realesrgan-gui-ubuntu.tar.xz` 不包含 Real-ESRGAN-ncnn-vulkan 的主程序和官方模型,请自行在[这里](https://github.com/xinntao/Real-ESRGAN/releases)下载后解压到 GUI 的主程序所在的目录。
38+
* Actions 中上传的是根据最新提交的代码打包的版本(相当于 Nightly),同样不包含 Real-ESRGAN-ncnn-vulkan 的主程序和官方模型
3939
* 如果需要从源代码运行,请使用 Python 3.10 或以上版本,执行 `pip install -r requirements.txt` 安装依赖,将 Real-ESRGAN-ncnn-vulkan 解压到项目目录,然后执行 `main.py`
4040
* 在其它的 Linux 发行版中可能也可以运行本项目,不过我没有进行测试。
41+
* 你也可以自己下载更多的[扩展模型](#扩展模型),将模型的文件名相同的 `bin``param` 文件放在 `models` 目录,主程序在启动后会自动识别到这些模型。
4142

4243
</details>
4344

@@ -59,6 +60,11 @@ sh Build-macOS-arm64.sh
5960

6061
> ⚠️ 由于我没有运行 macOS 的设备,因此可能无法处理和 macOS 相关的使用问题。
6162
63+
### 相关项目
64+
65+
* 在 Android 上使用 Real-ESRGAN:[tumuyan/RealSR-NCNN-Android](https://github.com/tumuyan/RealSR-NCNN-Android)
66+
* 通过 Vapoursynth 对视频使用 Real-ESRGAN:[HolyWu/vs-realesrgan](https://github.com/HolyWu/vs-realesrgan)
67+
6268
## 功能介绍
6369

6470
在原版支持的功能的基础上,增加了以下功能:
@@ -113,7 +119,7 @@ sh Build-macOS-arm64.sh
113119

114120
对于同一系列模型的不同倍率版本,建议选择等于或大于想要将图片放大的倍率的版本。例如在想要将图片放大到 3x 但是只有 x2 和 x4 模型的情况下,应该选择 x4 的模型。
115121

116-
带有 `animevideo` 的几个模型是针对二次元视频使用的,特点是模型文件较小以及处理速度较快(我自己的测试是 `realesrgan-x4plus-anime` 的 1.5x 到 3x 不等)。不过这个 GUI 并不会考虑加入视频处理功能,如果需要放大视频的话可以考虑使用 [VapourSynth 的相关插件](https://github.com/HolyWu/vs-realesrgan),并且确定你的显卡不会跑到冒烟……
122+
带有 `animevideo` 的几个模型是针对二次元视频使用的,特点是模型文件较小以及处理速度较快(我自己的测试是 `realesrgan-x4plus-anime` 的 1.5x 到 3x 不等)。不过这个 GUI 并不会考虑加入视频处理功能
117123

118124
### 拆分大小的作用
119125

@@ -158,6 +164,14 @@ GIF 只支持最多 256 种 RGB 颜色的调色板并设定其中一种颜色为
158164

159165
如果因为配置文件的问题导致程序不能运行的话,可以先尝试将配置文件删除。
160166

167+
### 扩展模型
168+
169+
除了 Real-ESRGAN 的官方模型,你也可以从 [Upscale Wiki](https://upscale.wiki/wiki/Model_Database) 下载更多的扩展模型,对于某些图片可能会有比官方模型更好的效果,请根据实际情况自由尝试。
170+
171+
这些模型使用的是 PyTorch 的 `pth` 格式,而不是 NCNN 的 `bin``param` 格式,因此需要进行转换,具体的操作方法可以参见 RealSR-NCNN-Android 的原作者提供的[教程](https://note.youdao.com/ynoteshare/?id=2b001cd4175ab46d2ce11ecb5a6d84ff)。为了识别模型的放大倍数,请确保模型的文件名中有类似 `x4``4x` 的字样。
172+
173+
可以在[这里](https://github.com/TransparentLC/realesrgan-gui/releases/tag/additional-models)下载一些转换好的模型。
174+
161175
## 借物表
162176

163177
* [Pillow](https://github.com/python-pillow/Pillow)

main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import configparser
33
import notifypy
44
import os
5+
import re
56
import sys
67
import time
78
import threading
@@ -41,10 +42,8 @@ def __init__(self, parent: tk.Tk):
4142
self.modelFactors: dict[str, int] = {}
4243
for m in self.models:
4344
self.modelFactors[m] = 4
44-
for i in range(2, 5):
45-
if f'x{i}' in m:
46-
self.modelFactors[m] = i
47-
break
45+
if s := re.search(r'(\d+)x|x(\d+)', m):
46+
self.modelFactors[m] = int(s.group(1) or s.group(2))
4847

4948
self.downsample = (
5049
('Lanczos', Image.Resampling.LANCZOS),
@@ -143,7 +142,10 @@ def setupWidgets(self):
143142
self.frameModel.grid(row=0, column=1, sticky=tk.NSEW)
144143
ttk.Label(self.frameModel, text=i18n.getTranslatedString('UsedModel')).pack(padx=10, pady=5, fill=tk.X)
145144
self.comboModel = ttk.Combobox(self.frameModel, state='readonly', values=self.models, textvariable=self.varstrModel)
146-
self.comboModel.current(self.models.index(self.varstrModel.get()))
145+
if self.varstrModel.get() in self.models:
146+
self.comboModel.current(self.models.index(self.varstrModel.get()))
147+
else:
148+
self.varstrModel.set(self.models[0])
147149
self.comboModel.pack(padx=10, pady=5, fill=tk.X)
148150
self.comboModel.bind('<<ComboboxSelected>>', lambda e: e.widget.select_clear())
149151
self.frameResize = ttk.Frame(self.frameBasicConfigBottom)

0 commit comments

Comments
 (0)