BasicSRは、ESRGANのauthorによる様々なSR手法の実装がまとめられたレポジトリです。
実際に実験を行うために動かすにあたって所々修正を加えています(細かい変更についてはこのフォークしたレポジトリのinitial commit の差分を参照)が、大幅な仕様変更などはないので、上の元の開発者によるREADMEを読むとおおよその使い方はわかるかと思います。
このレポジトリでは、optionファイルを利用することで一つの実行用ファイル(/basicsr/{train.py,test.py}
)で多くのモデルを動かせるようにしてあります。
ライブラリ化が進んでいるため、階層構造などはわかりやすいものの、コードがかなり切り分けられているため細かいコードを追っていくのが少し大変です。
basicsr/train.py
を解読するためには、主にbasicsr/models
、basicsr/data
にあるモジュールを理解していく必要があるため、初めに時間をかけてコードを読んで理解を深めるとその後の開発がスムーズに進められると思います(僕はあまり理解しきらないまま進めていたことで余計時間がかかった節がありました)。
reedbush上での環境構築にはかなり手間取ってしまいました。 PyTorch、cudaあたりのバージョンの管理などがわかりにくく理解するのに時間がかかったのですが、ひとまずreedbushのジョブ実行の仕組みなどを初めに把握しておくとわかりやすくなるかと思います。
必要なライブラリ等は元のレポジトリのREADMEにもあるようにrequirements.txt
に記されているのですが、たしかreedbushで単純にpip install
をしようとすると権限がない場合があるため、--prefix
オプションなどを利用して権限がある場所にインストールし、PYTHONUSERBASE
にその場所を指定しておくことで問題なく使えるようになります。
ひとまずreedbush_scripts/
に実際に用いたジョブスクリプトをいくつか置いているので、そちらのような形でreedbushのmoduleを利用するとうまく動くと思います。
datasetについては、datasets/
に置いてoptionファイルで指定することで学習に利用することができます。
詳しくはoptionsなどのREADMEなどを参照してください。
options/
には、参考に実験で用いたファイルの一部を置いています。
実際に用いたdatasetについては別途ドライブなどでシェアします。
English | 简体中文 GitHub | Gitee码云
Google Colab: GitHub Link | Google Drive Link
📁 Datasets ⏬ Google Drive ⏬ 百度网盘 (提取码:basr)
📈 Training curves in wandb
💻 Commands for training and testing
⚡ HOWTOs
BasicSR (Basic Super Restoration) is an open source image and video restoration toolbox based on PyTorch, such as super-resolution, denoise, deblurring, JPEG artifacts removal, etc.
(ESRGAN, EDVR, DNI, SFTGAN)
(HandyView, HandyFigure, HandyCrawler, HandyWriting)
- Nov 29, 2020. Add ESRGAN and DFDNet colab demo.
- Sep 8, 2020. Add blind face restoration inference codes: DFDNet.
- Aug 27, 2020. Add StyleGAN2 training and testing codes: StyleGAN2.
More
- Sep 8, 2020. Add blind face restoration inference codes: DFDNet.
ECCV20: Blind Face Restoration via Deep Multi-scale Component Dictionaries
Xiaoming Li, Chaofeng Chen, Shangchen Zhou, Xianhui Lin, Wangmeng Zuo and Lei Zhang - Aug 27, 2020. Add StyleGAN2 training and testing codes.
CVPR20: Analyzing and Improving the Image Quality of StyleGAN
Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen and Timo Aila - Aug 19, 2020. A brand-new BasicSR v1.0.0 online.
We provides simple pipelines to train/test/inference models for quick start. These pipelines/commands cannot cover all the cases and more details are in the following sections.
GAN | |||||
---|---|---|---|---|---|
StyleGAN2 | Train | Inference | |||
Face Restoration | |||||
DFDNet | - | Inference | |||
Super Resolution | |||||
ESRGAN | TODO | TODO | SRGAN | TODO | TODO |
EDSR | TODO | TODO | SRResNet | TODO | TODO |
RCAN | TODO | TODO | |||
EDVR | TODO | TODO | DUF | - | TODO |
BasicVSR | TODO | TODO | TOF | - | TODO |
Deblurring | |||||
DeblurGANv2 | - | TODO | |||
Denoise | |||||
RIDNet | - | TODO | CBDNet | - | TODO |
- Python >= 3.7 (Recommend to use Anaconda or Miniconda)
- PyTorch >= 1.3
- NVIDIA GPU + CUDA
-
Clone repo
git clone https://github.com/xinntao/BasicSR.git
-
Install dependent packages
cd BasicSR pip install -r requirements.txt
-
Install BasicSR
Please run the following commands in the BasicSR root path to install BasicSR:
(Make sure that your GCC version: gcc >= 5)
If you do not need the cuda extensions:
dcn for EDVR
upfirdn2d and fused_act for StyleGAN2
please add--no_cuda_ext
when installingpython setup.py develop --no_cuda_ext
If you use the EDVR and StyleGAN2 model, the above cuda extensions are necessary.
python setup.py develop
You may also want to specify the CUDA paths:
CUDA_HOME=/usr/local/cuda \ CUDNN_INCLUDE_DIR=/usr/local/cuda \ CUDNN_LIB_DIR=/usr/local/cuda \ python setup.py develop
Note that BasicSR is only tested in Ubuntu, and may be not suitable for Windows. You may try Windows WSL with CUDA supports :-) (It is now only available for insider build with Fast ring).
Please see project boards.
- Please refer to DatasetPreparation.md for more details.
- The descriptions of currently supported datasets (
torch.utils.data.Dataset
classes) are in Datasets.md.
- Training and testing commands: Please see TrainTest.md for the basic usage.
- Options/Configs: Please refer to Config.md.
- Logging: Please refer to Logging.md.
- The descriptions of currently supported models are in Models.md.
- Pre-trained models and log examples are available in ModelZoo.md.
- We also provide training curves in wandb:
Please see DesignConvention.md for the designs and conventions of the BasicSR codebase.
The figure below shows the overall framework. More descriptions for each component:
Datasets.md | Models.md | Config.md | Logging.md
This project is released under the Apache 2.0 license.
More details about license and acknowledgement are in LICENSE.
If BasicSR helps your research or work, please consider citing BasicSR.
The following is a BibTeX reference. The BibTeX entry requires the url
LaTeX package.
@misc{wang2020basicsr,
author = {Xintao Wang and Ke Yu and Kelvin C.K. Chan and
Chao Dong and Chen Change Loy},
title = {BasicSR},
howpublished = {\url{https://github.com/xinntao/BasicSR}},
year = {2020}
}
Xintao Wang, Ke Yu, Kelvin C.K. Chan, Chao Dong and Chen Change Loy. BasicSR. https://github.com/xinntao/BasicSR, 2020.
If you have any question, please email [email protected]
.