diff --git a/FAQ.md b/FAQ.md index f358641..0f5fc85 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,5 +1,7 @@ # FAQ -1. **How to select models?** +1. **How to select models?**
+A: Please refer to [docs/model_zoo.md](docs/model_zoo.md) -A: TODO. +1. **Can `face_enhance` be used for anime images/animation videos?**
+A: No, it can only be used for real faces. It is recommended not to use this option for anime images/animation videos to save GPU memory. diff --git a/README.md b/README.md index 2ecaf31..9cea171 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ 1. [Colab Demo](https://colab.research.google.com/drive/1k2Zod6kSHEvraybHl50Lys0LerhyTMCo?usp=sharing) for Real-ESRGAN google colab logo. 2. [Colab Demo](https://colab.research.google.com/drive/1yNl9ORUxxlL4N0keJa2SEPB61imPQd1B?usp=sharing) for Real-ESRGAN (**anime videos**) google colab logo. -3. Portable [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-macos.zip) **executable files for Intel/AMD/Nvidia GPU**. You can find more information [here](#Portable-executable-files). The ncnn implementation is in [Real-ESRGAN-ncnn-vulkan](https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan). +3. Portable [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip) **executable files for Intel/AMD/Nvidia GPU**. You can find more information [here](#Portable-executable-files). The ncnn implementation is in [Real-ESRGAN-ncnn-vulkan](https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan). Real-ESRGAN aims at developing **Practical Algorithms for General Image/Video Restoration**.
We extend the powerful ESRGAN to a practical restoration application (namely, Real-ESRGAN), which is trained with pure synthetic data. :art: Real-ESRGAN needs your contributions. Any contributions are welcome, such as new features/models/typo fixes/suggestions/maintenance, *etc*. See [CONTRIBUTING.md](CONTRIBUTING.md). All contributors are list [here](README.md#hugs-acknowledgement). -:question: Frequently Asked Questions can be found in [FAQ.md](FAQ.md) (Well, it is still empty there =-=||). +:question: Frequently Asked Questions can be found in [FAQ.md](FAQ.md). :milky_way: Thanks for your valuable feedbacks/suggestions. All the feedbacks are updated in [feedback.md](feedback.md). @@ -118,7 +118,7 @@ If you have some images that Real-ESRGAN could not well restored, please also op ### Portable executable files -You can download [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-macos.zip) **executable files for Intel/AMD/Nvidia GPU**. +You can download [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip) **executable files for Intel/AMD/Nvidia GPU**. This executable file is **portable** and includes all the binaries and models required. No CUDA or PyTorch environment is needed.
@@ -133,8 +133,7 @@ We have provided five models: 1. realesrgan-x4plus (default) 2. realesrnet-x4plus 3. realesrgan-x4plus-anime (optimized for anime images, small model size) -4. RealESRGANv2-animevideo-xsx2 (anime video, X2) -5. RealESRGANv2-animevideo-xsx4 (anime video, X4) +4. realesr-animevideov3 (animation video) You can use the `-n` argument for other models, for example, `./realesrgan-ncnn-vulkan.exe -i input.jpg -o output.png -n realesrnet-x4plus` @@ -147,23 +146,21 @@ You can use the `-n` argument for other models, for example, `./realesrgan-ncnn- Usage: realesrgan-ncnn-vulkan.exe -i infile -o outfile [options]... -h show this help - -v verbose output -i input-path input image path (jpg/png/webp) or directory -o output-path output image path (jpg/png/webp) or directory - -s scale upscale ratio (4, default=4) + -s scale upscale ratio (can be 2, 3, 4. default=4) -t tile-size tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu - -m model-path folder path to pre-trained models(default=models) - -n model-name model name (default=realesrgan-x4plus, can be realesrgan-x4plus | realesrgan-x4plus-anime | realesrnet-x4plus) - -g gpu-id gpu device to use (default=0) can be 0,1,2 for multi-gpu + -m model-path folder path to the pre-trained models. default=models + -n model-name model name (default=realesr-animevideov3, can be realesr-animevideov3 | realesrgan-x4plus | realesrgan-x4plus-anime | realesrnet-x4plus) + -g gpu-id gpu device to use (default=auto) can be 0,1,2 for multi-gpu -j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu - -x enable tta mode + -x enable tta mode" -f format output image format (jpg/png/webp, default=ext/png) + -v verbose output ``` Note that it may introduce block inconsistency (and also generate slightly different results from the PyTorch implementation), because this executable file first crops the input image into several tiles, and then processes them separately, finally stitches together. -This executable file is based on the wonderful [Tencent/ncnn](https://github.com/Tencent/ncnn) and [realsr-ncnn-vulkan](https://github.com/nihui/realsr-ncnn-vulkan) by [nihui](https://github.com/nihui). - --- ## :wrench: Dependencies and Installation @@ -236,7 +233,7 @@ Results are in the `results` folder ```console Usage: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile -o outfile [options]... -A common command: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile --outscale 3.5 --half --face_enhance +A common command: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile --outscale 3.5 --face_enhance -h show this help -i --input Input image or folder. Default: inputs @@ -246,11 +243,10 @@ A common command: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile --suffix Suffix of the restored image. Default: out -t, --tile Tile size, 0 for no tile during testing. Default: 0 --face_enhance Whether to use GFPGAN to enhance face. Default: False - --half Whether to use half precision during inference. Default: False + --fp32 Use fp32 precision during inference. Default: fp16 (half precision). --ext Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto ``` - ## :european_castle: Model Zoo Please see [docs/model_zoo.md](docs/model_zoo.md) diff --git a/README_CN.md b/README_CN.md index 7c28020..18cb9bf 100644 --- a/README_CN.md +++ b/README_CN.md @@ -16,7 +16,7 @@ 1. Real-ESRGAN的[Colab Demo](https://colab.research.google.com/drive/1k2Zod6kSHEvraybHl50Lys0LerhyTMCo?usp=sharing) google colab logo. 2. Real-ESRGAN的 **动漫视频** 的[Colab Demo](https://colab.research.google.com/drive/1yNl9ORUxxlL4N0keJa2SEPB61imPQd1B?usp=sharing) google colab logo. -3. **支持Intel/AMD/Nvidia显卡**的绿色版exe文件: [Windows版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-windows.zip) / [Linux版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-ubuntu.zip) / [macOS版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-macos.zip),详情请移步[这里](#便携版(绿色版)可执行文件)。NCNN的实现在 [Real-ESRGAN-ncnn-vulkan](https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan)。 +3. **支持Intel/AMD/Nvidia显卡**的绿色版exe文件: [Windows版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [macOS版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip),详情请移步[这里](#便携版(绿色版)可执行文件)。NCNN的实现在 [Real-ESRGAN-ncnn-vulkan](https://github.com/xinntao/Real-ESRGAN-ncnn-vulkan)。 Real-ESRGAN 的目标是开发出**实用的图像/视频修复算法**。
我们在 ESRGAN 的基础上使用纯合成的数据来进行训练,以使其能被应用于实际的图片修复的场景(顾名思义:Real-ESRGAN)。 @@ -115,7 +115,7 @@ Real-ESRGAN 将会被长期支持,我会在空闲的时间中持续维护更 ### 便携版(绿色版)可执行文件 -你可以下载**支持Intel/AMD/Nvidia显卡**的绿色版exe文件: [Windows版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-windows.zip) / [Linux版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-ubuntu.zip) / [macOS版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-macos.zip)。 +你可以下载**支持Intel/AMD/Nvidia显卡**的绿色版exe文件: [Windows版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [macOS版](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip)。 绿色版指的是这些exe你可以直接运行(放U盘里拷走都没问题),因为里面已经有所需的文件和模型了。它不需要 CUDA 或者 PyTorch运行环境。
@@ -130,8 +130,7 @@ Real-ESRGAN 将会被长期支持,我会在空闲的时间中持续维护更 1. realesrgan-x4plus(默认) 2. reaesrnet-x4plus 3. realesrgan-x4plus-anime(针对动漫插画图像优化,有更小的体积) -4. RealESRGANv2-animevideo-xsx2 (针对动漫视频, X2) -5. RealESRGANv2-animevideo-xsx4 (针对动漫视频, X4) +4. realesr-animevideov3 (针对动漫视频) 你可以通过`-n`参数来使用其他模型,例如`./realesrgan-ncnn-vulkan.exe -i 二次元图片.jpg -o 二刺螈图片.png -n realesrgan-x4plus-anime` @@ -144,23 +143,21 @@ Real-ESRGAN 将会被长期支持,我会在空闲的时间中持续维护更 Usage: realesrgan-ncnn-vulkan.exe -i infile -o outfile [options]... -h show this help - -v verbose output -i input-path input image path (jpg/png/webp) or directory -o output-path output image path (jpg/png/webp) or directory - -s scale upscale ratio (4, default=4) + -s scale upscale ratio (can be 2, 3, 4. default=4) -t tile-size tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu - -m model-path folder path to pre-trained models(default=models) - -n model-name model name (default=realesrgan-x4plus, can be realesrgan-x4plus | realesrgan-x4plus-anime | realesrnet-x4plus) - -g gpu-id gpu device to use (default=0) can be 0,1,2 for multi-gpu + -m model-path folder path to the pre-trained models. default=models + -n model-name model name (default=realesr-animevideov3, can be realesr-animevideov3 | realesrgan-x4plus | realesrgan-x4plus-anime | realesrnet-x4plus) + -g gpu-id gpu device to use (default=auto) can be 0,1,2 for multi-gpu -j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu - -x enable tta mode + -x enable tta mode" -f format output image format (jpg/png/webp, default=ext/png) + -v verbose output ``` 由于这些exe文件会把图像分成几个板块,然后来分别进行处理,再合成导出,输出的图像可能会有一点割裂感(而且可能跟PyTorch的输出不太一样) -这些exe文件均基于[Tencent/ncnn](https://github.com/Tencent/ncnn)以及[nihui](https://github.com/nihui)的[realsr-ncnn-vulkan](https://github.com/nihui/realsr-ncnn-vulkan),感谢! - --- ## :wrench: 依赖以及安装 @@ -233,7 +230,7 @@ python inference_realesrgan.py -n RealESRGAN_x4plus_anime_6B -i inputs ```console Usage: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile -o outfile [options]... -A common command: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile --outscale 3.5 --half --face_enhance +A common command: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile --outscale 3.5 --face_enhance -h show this help -i --input Input image or folder. Default: inputs @@ -243,7 +240,7 @@ A common command: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile --suffix Suffix of the restored image. Default: out -t, --tile Tile size, 0 for no tile during testing. Default: 0 --face_enhance Whether to use GFPGAN to enhance face. Default: False - --half Whether to use half precision during inference. Default: False + --fp32 Whether to use half precision during inference. Default: False --ext Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto ``` diff --git a/docs/anime_model.md b/docs/anime_model.md index 45c1882..5d1c8dc 100644 --- a/docs/anime_model.md +++ b/docs/anime_model.md @@ -15,7 +15,7 @@ The following is a video comparison with sliding bar. You may need to use the full-screen mode for better visual quality, as the original image is large; otherwise, you may encounter aliasing issue. -https://user-images.githubusercontent.com/17445847/131535127-613250d4-f754-4e20-9720-2f9608ad0675.mp4 + ## How to Use @@ -32,7 +32,7 @@ python inference_realesrgan.py -n RealESRGAN_x4plus_anime_6B -i inputs ### ncnn Executable File -Download the latest portable [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/realesrgan-ncnn-vulkan-20211212-macos.zip) **executable files for Intel/AMD/Nvidia GPU**. +Download the latest portable [Windows](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-windows.zip) / [Linux](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-ubuntu.zip) / [MacOS](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesrgan-ncnn-vulkan-20220424-macos.zip) **executable files for Intel/AMD/Nvidia GPU**. Taking the Windows as example, run: @@ -64,6 +64,6 @@ We compare Real-ESRGAN-anime with [waifu2x](https://github.com/nihui/waifu2x-ncn The following are video comparisons with sliding bar. You may need to use the full-screen mode for better visual quality, as the original image is large; otherwise, you may encounter aliasing issue. -https://user-images.githubusercontent.com/17445847/131536647-a2fbf896-b495-4a9f-b1dd-ca7bbc90101a.mp4 + -https://user-images.githubusercontent.com/17445847/131536742-6d9d82b6-9765-4296-a15f-18f9aeaa5465.mp4 + diff --git a/docs/model_zoo.md b/docs/model_zoo.md index 1a30ebd..f41dee8 100644 --- a/docs/model_zoo.md +++ b/docs/model_zoo.md @@ -1,9 +1,8 @@ # :european_castle: Model Zoo -- [:european_castle: Model Zoo](#european_castle-model-zoo) - - [For General Images](#for-general-images) - - [For Anime Images](#for-anime-images) - - [For Anime Videos](#for-anime-videos) +- [For General Images](#for-general-images) +- [For Anime Images](#for-anime-images) +- [For Anime Videos](#for-anime-videos) --- @@ -23,7 +22,7 @@ The following models are **discriminators**, which are usually used for fine-tun | [RealESRGAN_x4plus_netD](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth) | RealESRGAN_x4plus | | [RealESRGAN_x2plus_netD](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x2plus_netD.pth) | RealESRGAN_x2plus | -## For Anime Images +## For Anime Images / Illustrations | Models | Scale | Description | | ------------------------------------------------------------------------------------------------------------------------------ | :---- | :---------------------------------------------------------- | @@ -35,12 +34,14 @@ The following models are **discriminators**, which are usually used for fine-tun | ---------------------------------------------------------------------------------------------------------------------------------------- | :------------------------- | | [RealESRGAN_x4plus_anime_6B_netD](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B_netD.pth) | RealESRGAN_x4plus_anime_6B | -## For Anime Videos +## For Animation Videos | Models | Scale | Description | | ---------------------------------------------------------------------------------------------------------------------------------- | :---- | :----------------------------- | -| [RealESRGANv2-animevideo-xsx2](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/RealESRGANv2-animevideo-xsx2.pth) | X2 | Anime video model with XS size | -| [RealESRGANv2-animevideo-xsx4](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.3.0/RealESRGANv2-animevideo-xsx4.pth) | X4 | Anime video model with XS size | +| [realesr-animevideov3](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth) | X41 | Anime video model with XS size | + +Note:
+1 This model can also be used for X1, X2, X3. The following models are **discriminators**, which are usually used for fine-tuning. diff --git a/inference_realesrgan.py b/inference_realesrgan.py index cd8991e..be39771 100644 --- a/inference_realesrgan.py +++ b/inference_realesrgan.py @@ -18,9 +18,8 @@ def main(): '--model_name', type=str, default='RealESRGAN_x4plus', - help=('Model names: RealESRGAN_x4plus | RealESRNet_x4plus | RealESRGAN_x4plus_anime_6B | RealESRGAN_x2plus' - 'RealESRGANv2-anime-xsx2 | RealESRGANv2-animevideo-xsx2-nousm | RealESRGANv2-animevideo-xsx2' - 'RealESRGANv2-anime-xsx4 | RealESRGANv2-animevideo-xsx4-nousm | RealESRGANv2-animevideo-xsx4')) + help=('Model names: RealESRGAN_x4plus | RealESRNet_x4plus | RealESRGAN_x4plus_anime_6B | RealESRGAN_x2plus | ' + 'realesr-animevideov3')) parser.add_argument('-o', '--output', type=str, default='results', help='Output folder') parser.add_argument('-s', '--outscale', type=float, default=4, help='The final upsampling scale of the image') parser.add_argument('--suffix', type=str, default='out', help='Suffix of the restored image') @@ -28,7 +27,8 @@ def main(): parser.add_argument('--tile_pad', type=int, default=10, help='Tile padding') parser.add_argument('--pre_pad', type=int, default=0, help='Pre padding size at each border') parser.add_argument('--face_enhance', action='store_true', help='Use GFPGAN to enhance face') - parser.add_argument('--half', action='store_true', help='Use half precision during inference') + parser.add_argument( + '--fp32', action='store_true', help='Use fp32 precision during inference. Default: fp16 (half precision).') parser.add_argument( '--alpha_upsampler', type=str, @@ -52,14 +52,7 @@ def main(): elif args.model_name in ['RealESRGAN_x2plus']: # x2 RRDBNet model model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2) netscale = 2 - elif args.model_name in [ - 'RealESRGANv2-anime-xsx2', 'RealESRGANv2-animevideo-xsx2-nousm', 'RealESRGANv2-animevideo-xsx2' - ]: # x2 VGG-style model (XS size) - model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=16, upscale=2, act_type='prelu') - netscale = 2 - elif args.model_name in [ - 'RealESRGANv2-anime-xsx4', 'RealESRGANv2-animevideo-xsx4-nousm', 'RealESRGANv2-animevideo-xsx4' - ]: # x4 VGG-style model (XS size) + elif args.model_name in ['realesr-animevideov3']: # x4 VGG-style model (XS size) model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=16, upscale=4, act_type='prelu') netscale = 4 @@ -78,7 +71,7 @@ def main(): tile=args.tile, tile_pad=args.tile_pad, pre_pad=args.pre_pad, - half=args.half) + half=not args.fp32) if args.face_enhance: # Use GFPGAN for face enhancement from gfpgan import GFPGANer @@ -120,7 +113,10 @@ def main(): extension = args.ext if img_mode == 'RGBA': # RGBA images should be saved in png format extension = 'png' - save_path = os.path.join(args.output, f'{imgname}_{args.suffix}.{extension}') + if args.suffix == '': + save_path = os.path.join(args.output, f'{imgname}.{extension}') + else: + save_path = os.path.join(args.output, f'{imgname}_{args.suffix}.{extension}') cv2.imwrite(save_path, output)