未验证 提交 9f36b055 编写于 作者: L LielinJiang 提交者: GitHub

[Cherrypick-2.0.0-beta] add dped docs (#172)

* add dped docs
上级 ea879d73
......@@ -29,7 +29,7 @@ opt = parser.parse_args()
# define input and target directories
cur_path = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(cur_path, './paths.yml'), 'r') as stream:
PATHS = yaml.load(stream)
PATHS = yaml.load(stream, Loader=yaml.SafeLoader)
def noise_patch(rgb_img, sp, max_var, min_mean):
......
......@@ -50,7 +50,7 @@ opt = parser.parse_args()
# define input and target directories
cur_path = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(cur_path, './paths.yml'), 'r') as stream:
PATHS = yaml.load(stream)
PATHS = yaml.load(stream, Loader=yaml.SafeLoader)
if opt.dataset == 'df2k':
path_sdsr = PATHS['datasets']['df2k'] + '/generated/sdsr/'
......
......@@ -53,8 +53,9 @@ parser.add_argument('--upscale_factor',
opt = parser.parse_args()
# define input and target directories
with open('./paths.yml', 'r') as stream:
PATHS = yaml.load(stream)
cur_path = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(cur_path, './paths.yml'), 'r') as stream:
PATHS = yaml.load(stream, Loader=yaml.SafeLoader)
if opt.dataset == 'df2k':
path_sdsr = PATHS['datasets']['df2k'] + '/generated/sdsr/'
......
......@@ -7,7 +7,7 @@ dped:
clean:
hr:
train: './data/ntire20/DPEDiphone-tr-x'
valid: './data/datasets/ntire20/DPEDiphone-va'
valid: './data/ntire20/DPEDiphone-va'
datasets:
df2k: 'data/DF2K'
dped: 'data/DPED'
......@@ -81,6 +81,22 @@
python ./data/realsr_preprocess/collect_noise.py --dataset df2k --artifacts tdsr
```
#### Prepare dataset for realsr dped model
Download dataset from [NTIRE 2020 RWSR](https://competitions.codalab.org/competitions/22220#participate) and unzip it to your path.
Unzip DPEDiphone-tr-x.zip and DPEDiphone-va.zip to ``PaddleGAN/data/ntire20`` directory.
Use [KernelGAN](https://github.com/sefibk/KernelGAN) to generate kernels from source images. Clone the repo here. Replace SOURCE_PATH with specific path and run:
```
python train.py --X4 --input-dir SOURCE_PATH
```
for convenient, we provide [DPED_KERNEL.tar](https://paddlegan.bj.bcebos.com/datasets/DPED_KERNEL.tar). You can download it to ``PaddleGAN/data/DPED_KERNEL``
Run the following commands:
```
python ./data/realsr_preprocess/create_kernel_dataset.py --dataset dped --artifacts clean --kernel_path data/DPED_KERNEL
python ./data/realsr_preprocess/collect_noise.py --dataset dped --artifacts clean
```
### 1.2.2 Train/Test
Datasets used in example is df2k, you can change it to your own dataset in the config file. The model used in example is RealSR, you can change other models by replacing the config file.
......
......@@ -43,7 +43,7 @@ class FirstOrderPredictor(BasePredictor):
find_best_frame=False,
best_frame=None):
if config is not None and isinstance(config, str):
self.cfg = yaml.load(config)
self.cfg = yaml.load(config, Loader=yaml.SafeLoader)
elif isinstance(config, dict):
self.cfg = config
elif config is None:
......
......@@ -96,7 +96,7 @@ def build_from_config(cfg, registry, default_args=None):
'`cfg` or `default_args` must contain the key "name", '
f'but got {cfg}\n{default_args}')
if not isinstance(registry, Registry):
raise TypeError('registry must be an mmcv.Registry object, '
raise TypeError('registry must be an ppgan.utils.Registry object, '
f'but got {type(registry)}')
if not (isinstance(default_args, dict) or default_args is None):
raise TypeError('default_args must be a dict or None, '
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册