forked from mindspore-Ecosystem/mindspore
!22427 Add SR_EA and ESR_EA to Model_zoo
Merge pull request !22427 from hjxcoder/sr_ea_branch4
This commit is contained in:
commit
ac3ef289d8
|
@ -0,0 +1,211 @@
|
|||
# Contents
|
||||
|
||||
- [Contents](#contents)
|
||||
- [Algorithm Introduction](#algorithm-introduction)
|
||||
- [Algorithm Description](#algorithm-description)
|
||||
- [Search Space and Searching Strategy](#search-space-and-searching-strategy)
|
||||
- [Configuring](#configuring)
|
||||
- [Application Scenarios](#application-scenarios)
|
||||
- [Dataset](#dataset)
|
||||
- [Requirements](#requirements)
|
||||
- [Hardware (Ascend)](#hardware-ascend)
|
||||
- [Framework](#framework)
|
||||
- [For more information, please check the resources below](#for-more-information-please-check-the-resources-below)
|
||||
- [Script Description](#script-description)
|
||||
- [Scripts and Sample Code](#scripts-and-sample-code)
|
||||
- [Script Parameter](#script-parameter)
|
||||
- [Training Process](#training-process)
|
||||
- [For training](#for-training)
|
||||
- [Evaluation](#evaluation)
|
||||
- [Evaluation Process](#evaluation-process)
|
||||
- [Evaluation Result](#evaluation-result)
|
||||
- [Performance](#performance)
|
||||
- [Inference Performance](#inference-performance)
|
||||
- [ModeZoo Homepage](#modezoo-homepage)
|
||||
|
||||
## Algorithm Introduction
|
||||
|
||||
Taking the advantage of the rapid development of GPU and deep convolutional network (DCNN), the visual quality of super-resolution is greatly improved, which makes image super-resolution widely used in real life.
|
||||
|
||||
At the same time, the model size of the super resolution network is increasing from 57K to 43M, and the computing workload reaches 10192G FLOPs (RDN). Meanwhile, the computing and storage budgets of mobile devices are limited, which constrains the application of the huge super-resolution models on mobile devices (for example, mobile phones, cameras, and smart homes). A lightweight super-resolution model is appealed for mobile applications.
|
||||
|
||||
Common methods for compressing a super-resolution model can be classified into two categories: a) manually designed efficient structural units (such as group convolution and recuresive); b) automatically search a lightweight entwork architecture. The existing architecture search algorithms are mainly focus on using convolution units and connections to search lightweight networks. However, the obtained network structure is very irregular and is not hardware friendly. Moreover, the entire backbone is calculated on a single scale, which means a huge computation workload.
|
||||
|
||||
We propose a network architecture search algorithm , which constructs a modular search space, takes the parameters and computations as constraints, and the network accuracy (PSNR) as the objective to search for a lightweight and fast super-resolution model. In this way, the network structure is hardware friendly. In addition, we compress the super-resolution network from three aspects: channel, convolution, and feature scale. The proposed algorithm has been published at AAAI 2020.
|
||||
|
||||
```text
|
||||
[1] Song, D.; Xu, C.; Jia, X.; Chen, Y.; Xu, C.; Wang, Y. Efficient Residual Dense Block Search for Image Super-Resolution[C]. AAAI 2020.
|
||||
```
|
||||
|
||||
## Algorithm Description
|
||||
|
||||
Firstly, the algorithm constructs a search space based on modules, takes the parameters and computations as constraints, and the network accuracy (PSNR) as the objective to search for an efficient super-resolution network structure. In addition, a high efficiency super-resolution module based on RDB is designed to compress the redundant information of super network from channel, convolution and characteristic scale. Finally, genetic algorithm is used to search for the number of each type of module, the corresponding location and the specific internal parameters. The following figure shows the algorithm framework.
|
||||
|
||||

|
||||
|
||||
We take RDN as the basic network structure and Efficient Dense Block (RDB) as the basic module, and searches for the number, the types and the internal parameters of the modules. You can assign the compression ratio of each module and the location of each module in the whole network during the search. We design three kinds of efficient residual-intensive modules, which compress the redundancy of channel, convolution and feature scale respectively. The detailed network structure is as follows:
|
||||
|
||||

|
||||
|
||||
The proposed algorithm has two steps : network structure search and full training. In order to speed up the search, the model evaluation is usually achieved by means of fast training. Fully train on a large data set needs to be performed after we have the searched candidates.
|
||||
|
||||
The following is an example of the searched:
|
||||
|
||||
```text
|
||||
['G_8_16_24', 'C_8_16_16', 'G_4_16_24', 'G_8_16_16', 'S_4_24_32', 'C_8_16_48', 'S_4_16_24', 'G_6_16_24', 'G_8_16_16', 'C_8_16_24', 'S_8_16_16', 'S_8_16_24', 'S_8_16_32', 'S_6_16_16', 'G_6_16_64', 'G_8_16_16', 'S_8_16_32']
|
||||
```
|
||||
|
||||
### Search Space and Searching Strategy
|
||||
|
||||
The efficient RDB is used as the basic modules for search. Considering the hardware efficiency, the number of convolutional channels is also a multiple of 16, for example, 16, 24, 32, 48, or 64. The algorithm mainly searches for the number of modules, the type of each location module, and the specific parameters (such as the number of convolutions and channels) in the model, and allocates the compression ratio of each aspect.
|
||||
|
||||
The search strategy is mainly based on evolutionary algorithms. Firstly, RDN is used as the basic structure framework to encode the global network, and a next generation population is generated through crossover and mutation. There are two selection modes for parents selection , which are tourament and roulette modes. The final high performance network structure is obtained through iterative evolution.
|
||||
|
||||
### Configuring
|
||||
|
||||
For details, see the configuration file esr_ea/esr_ea.yml in the sample code.
|
||||
|
||||
```yaml
|
||||
nas:
|
||||
search_space: # Set the network structure search parameters.
|
||||
type: SearchSpace
|
||||
modules: ['esrbody']
|
||||
esrbody:
|
||||
type: ESRN
|
||||
block_type: [S,G,C] # module
|
||||
conv_num: [4,6,8] # Number of convolutions in the module
|
||||
growth_rate: [8,16,24,32] # Number of convolutional channels in the module
|
||||
type_prob: [1,1,1] # Probability of module type selection
|
||||
conv_prob: [1,1,1] # Probability of selecting the number of convolutions
|
||||
growth_prob: [1,1,1,1] # Probability of selecting the number of convolution channel
|
||||
G0: 32 # Number of initial convolution channels
|
||||
scale: 2 # Scale of the super-distribution
|
||||
search_algorithm:
|
||||
type: ESRSearch
|
||||
codec: ESRCodec
|
||||
policy:
|
||||
num_generation: 20 # Number of iterations in evolution algorithm
|
||||
num_individual: 8 # Number of individuals in evolution algorithm
|
||||
num_elitism: 4 # Number of elites to be reserved
|
||||
mutation_rate: 0.05 # probability of mutation for each gene
|
||||
range:
|
||||
node_num: 20 # Upper limit of the modules
|
||||
min_active: 16 # Lower limit of the modules
|
||||
max_params: 325000 # Maximum parameters of network
|
||||
min_params: 315000 # Minimum parameters of network
|
||||
|
||||
|
||||
```
|
||||
|
||||
If other blocks need to be used as the basic modular structure or multiple types of blocks need to be searched.
|
||||
|
||||
## Application Scenarios
|
||||
|
||||
This method is used to search for low-level vision tasks, such as super-resolution, denoising, and de-mosaic. Currently, the RGB data is used for training. We use the DIV2K dataset in this repo. Other similar datasets can be used by simply change the config.
|
||||
|
||||
## Dataset
|
||||
|
||||
The benchmark datasets can be downloaded as follows:
|
||||
|
||||
[DIV2K](https://cv.snu.ac.kr/research/EDSR/DIV2K.tar).
|
||||
|
||||
## Requirements
|
||||
|
||||
### Hardware (Ascend)
|
||||
|
||||
> Prepare hardware environment with Ascend.
|
||||
|
||||
### Framework
|
||||
|
||||
> [MindSpore](https://www.mindspore.cn/install/en)
|
||||
|
||||
### For more information, please check the resources below
|
||||
|
||||
[MindSpore Tutorials](https://www.mindspore.cn/tutorials/en/r1.3/index.html)
|
||||
[MindSpore Python API](https://www.mindspore.cn/docs/api/en/r1.3/index.html)
|
||||
|
||||
## Script Description
|
||||
|
||||
### Scripts and Sample Code
|
||||
|
||||
```bash
|
||||
esr_ea
|
||||
├── eval.py # inference entry
|
||||
├── train.py # pre-training entry
|
||||
├── image
|
||||
│ ├── esr_arch.png # the illustration of esr_ea network
|
||||
│ └── esr_block.png #
|
||||
├── readme.md # Readme
|
||||
├── scripts
|
||||
│ ├── run_distributed.sh # pre-training script for all tasks
|
||||
└── src
|
||||
├── esr_ea.yml # options/hyper-parameters of esr_ea
|
||||
└── esr_ea_distributed.yml # options/hyper-parameters of esr_ea
|
||||
|
||||
```
|
||||
|
||||
### Script Parameter
|
||||
|
||||
> For details about hyperparameters, see src/esr_ea.yml.
|
||||
|
||||
## Training Process
|
||||
|
||||
### For training
|
||||
|
||||
```bash
|
||||
python3 train.py
|
||||
```
|
||||
|
||||
> Or one can run following script for all tasks.
|
||||
|
||||
```bash
|
||||
sh scripts/run_distributed.sh [RANK_TABLE_FILE]
|
||||
```
|
||||
|
||||
## Evaluation
|
||||
|
||||
### Evaluation Process
|
||||
|
||||
> Inference example:
|
||||
|
||||
Modify src/eval.yml:
|
||||
|
||||
```bash
|
||||
models_folder: [CHECKPOINT_PATH]
|
||||
```
|
||||
|
||||
```bash
|
||||
python3 eval.py
|
||||
```
|
||||
|
||||
### Evaluation Result
|
||||
|
||||
The result are evaluated by the value of PSNR, and the format is as following.
|
||||
|
||||
```bash
|
||||
INFO Best values: [{'worker_id': 82, 'performance': {'flops': 0.0, 'params': 516.339, 'PSNR': 41.08037491480157}}]
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
### Inference Performance
|
||||
|
||||
The Results on super resolution tasks are listed as below.
|
||||
|
||||
| Parameters | Ascend |
|
||||
| -------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| Model Version | V1 |
|
||||
| Resource | CentOs 8.2; Ascend 910; CPU 2.60GHz, 192cores; Memory 755G |
|
||||
| uploaded Date | 08/26/2021 (month/day/year) |
|
||||
| MindSpore Version | 1.2.0 |
|
||||
| Dataset | DIV2K Dataset |
|
||||
| Training Parameters | epoch=15000, batch_size = 16 |
|
||||
| Optimizer | Adam |
|
||||
| Loss Function | L1Loss |
|
||||
| Output | super resolution image |
|
||||
| PSNR | 41.08 |
|
||||
| Scripts | [esr_ea script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/research/cv/esr_ea) |
|
||||
|
||||
## ModeZoo Homepage
|
||||
|
||||
Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""eval script"""
|
||||
import vega
|
||||
|
||||
if __name__ == '__main__':
|
||||
vega.run('./src/eval.yml')
|
||||
vega.set_backend('mindspore', 'NPU')
|
Binary file not shown.
After Width: | Height: | Size: 208 KiB |
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
|
@ -0,0 +1 @@
|
|||
noah-vega
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
ulimit -u unlimited
|
||||
export DEVICE_NUM=8
|
||||
export RANK_SIZE=8
|
||||
|
||||
if [ $# != 1 ]
|
||||
then
|
||||
echo "Usage: sh run_distribution.sh [RANK_TABLE_FILE]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $1 ]
|
||||
then
|
||||
echo "error: RANK_TABLE_FILE=$1 is not a file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RANK_TABLE_FILE=$(realpath $1)
|
||||
export RANK_TABLE_FILE
|
||||
|
||||
python3 -m vega.tools.run_pipeline ../src/esr_ea_distributed.yml -b m -d NPU \
|
||||
> train.log 2>&1 &
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
ulimit -u unlimited
|
||||
export DEVICE_NUM=1
|
||||
export RANK_SIZE=1
|
||||
|
||||
if [ $# != 0 ]
|
||||
then
|
||||
echo "Usage: sh run_standalone.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 -m vega.tools.run_pipeline ../src/esr_ea.yml -b m -d NPU \
|
||||
> train.log 2>&1 &
|
|
@ -0,0 +1,182 @@
|
|||
general:
|
||||
backend: mindspore
|
||||
parallel_search: True
|
||||
parallel_fully_train: True
|
||||
|
||||
|
||||
pipeline: [nas, fully_train, benchmark_DIV2K, benchmark_Set5, benchmark_Set14, benchmark_BSDS100]
|
||||
|
||||
|
||||
nas:
|
||||
pipe_step:
|
||||
type: SearchPipeStep
|
||||
|
||||
dataset:
|
||||
type: DIV2K
|
||||
train:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_train/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
crop: 64
|
||||
hflip: true
|
||||
vflip: true
|
||||
rot90: true
|
||||
shuffle: true
|
||||
batch_size: 16
|
||||
fixed_size: true
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_valid/lr
|
||||
upscale: 2
|
||||
fixed_size: true
|
||||
crop: 64
|
||||
|
||||
search_space:
|
||||
type: SearchSpace
|
||||
modules: ['esrbody']
|
||||
esrbody:
|
||||
type: ESRN
|
||||
block_type: [S,G,C]
|
||||
conv_num: [4,6,8]
|
||||
growth_rate: [8,16,24,32]
|
||||
type_prob: [1,1,1]
|
||||
conv_prob: [1,1,1]
|
||||
growth_prob: [1,1,1,1]
|
||||
G0: 32
|
||||
scale: 2
|
||||
|
||||
search_algorithm:
|
||||
type: ESRSearch
|
||||
codec: ESRCodec
|
||||
policy:
|
||||
num_generation: 20
|
||||
num_individual: 8
|
||||
num_elitism: 4
|
||||
mutation_rate: 0.05
|
||||
range:
|
||||
node_num: 20
|
||||
min_active: 16
|
||||
max_params: 325000
|
||||
min_params: 315000
|
||||
|
||||
trainer:
|
||||
type: Trainer
|
||||
callbacks: ESRTrainerCallback
|
||||
epochs: 500
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0001 # 0.001 for mindspore
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [100,200]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
max_rgb: 255
|
||||
scale: 2
|
||||
cuda: True
|
||||
seed: 10
|
||||
|
||||
|
||||
fully_train:
|
||||
pipe_step:
|
||||
type: TrainPipeStep
|
||||
models_folder: "{local_base_path}/output/nas/"
|
||||
dataset:
|
||||
ref: nas.dataset
|
||||
trainer:
|
||||
type: Trainer
|
||||
callbacks: ESRTrainerCallback
|
||||
node_num: 20
|
||||
epochs: 15000
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0001
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [8000,12000,13500,14500]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
max_rgb: 255
|
||||
scale: 2
|
||||
seed: 10
|
||||
range:
|
||||
node_num: 20
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
|
||||
|
||||
benchmark_DIV2K:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
type: DIV2K
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
max_rgb: 255
|
||||
benchmark_Set5:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set5
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set5/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set5/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_Set14:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set14
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set14/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set14/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_BSDS100:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: BSDS100
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/BSDS100/hr
|
||||
root_LR: /cache/datasets/DIV2K/BSDS100/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
|
@ -0,0 +1,182 @@
|
|||
general:
|
||||
backend: mindspore
|
||||
parallel_search: False
|
||||
parallel_fully_train: False
|
||||
|
||||
|
||||
pipeline: [nas, fully_train, benchmark_DIV2K, benchmark_Set5, benchmark_Set14, benchmark_BSDS100]
|
||||
|
||||
|
||||
nas:
|
||||
pipe_step:
|
||||
type: SearchPipeStep
|
||||
|
||||
dataset:
|
||||
type: DIV2K
|
||||
train:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_train/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
crop: 64
|
||||
hflip: true
|
||||
vflip: true
|
||||
rot90: true
|
||||
shuffle: true
|
||||
batch_size: 16
|
||||
fixed_size: true
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_valid/lr
|
||||
upscale: 2
|
||||
fixed_size: true
|
||||
crop: 64
|
||||
|
||||
search_space:
|
||||
type: SearchSpace
|
||||
modules: ['esrbody']
|
||||
esrbody:
|
||||
type: ESRN
|
||||
block_type: [S,G,C]
|
||||
conv_num: [4,6,8]
|
||||
growth_rate: [8,16,24,32]
|
||||
type_prob: [1,1,1]
|
||||
conv_prob: [1,1,1]
|
||||
growth_prob: [1,1,1,1]
|
||||
G0: 32
|
||||
scale: 2
|
||||
|
||||
search_algorithm:
|
||||
type: ESRSearch
|
||||
codec: ESRCodec
|
||||
policy:
|
||||
num_generation: 20
|
||||
num_individual: 8
|
||||
num_elitism: 4
|
||||
mutation_rate: 0.05
|
||||
range:
|
||||
node_num: 20
|
||||
min_active: 16
|
||||
max_params: 325000
|
||||
min_params: 315000
|
||||
|
||||
trainer:
|
||||
type: Trainer
|
||||
callbacks: ESRTrainerCallback
|
||||
epochs: 500
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0001 # 0.001 for mindspore
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [100,200]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
max_rgb: 255
|
||||
scale: 2
|
||||
cuda: True
|
||||
seed: 10
|
||||
|
||||
|
||||
fully_train:
|
||||
pipe_step:
|
||||
type: TrainPipeStep
|
||||
models_folder: "{local_base_path}/output/nas/"
|
||||
dataset:
|
||||
ref: nas.dataset
|
||||
trainer:
|
||||
type: Trainer
|
||||
callbacks: ESRTrainerCallback
|
||||
node_num: 20
|
||||
epochs: 15000
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0001
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [8000,12000,13500,14500]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
max_rgb: 255
|
||||
scale: 2
|
||||
seed: 10
|
||||
range:
|
||||
node_num: 20
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
|
||||
|
||||
benchmark_DIV2K:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
type: DIV2K
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
max_rgb: 255
|
||||
benchmark_Set5:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set5
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set5/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set5/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_Set14:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set14
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set14/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set14/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_BSDS100:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: BSDS100
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/BSDS100/hr
|
||||
root_LR: /cache/datasets/DIV2K/BSDS100/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
|
@ -0,0 +1,61 @@
|
|||
general:
|
||||
backend: mindspore
|
||||
|
||||
pipeline: [eval]
|
||||
|
||||
eval:
|
||||
pipe_step:
|
||||
type: TrainPipeStep
|
||||
models_folder: ~
|
||||
trainer:
|
||||
type: Trainer
|
||||
with_train: False
|
||||
callbacks: ESRTrainerCallback
|
||||
node_num: 20
|
||||
epochs: 15000
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0001
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [8000,12000,13500,14500]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
max_rgb: 255
|
||||
scale: 2
|
||||
seed: 10
|
||||
range:
|
||||
node_num: 20
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
|
||||
dataset:
|
||||
type: DIV2K
|
||||
train:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_train/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
crop: 64
|
||||
hflip: true
|
||||
vflip: true
|
||||
rot90: true
|
||||
shuffle: true
|
||||
batch_size: 16
|
||||
fixed_size: true
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_valid/lr
|
||||
upscale: 2
|
||||
fixed_size: true
|
||||
crop: 64
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""train"""
|
||||
import vega
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
vega.run('./src/esr_ea.yml')
|
||||
vega.set_backend('mindspore', 'NPU')
|
|
@ -0,0 +1,163 @@
|
|||
# Contents
|
||||
|
||||
- [Contents](#contents)
|
||||
- [Algorithm Introduction](#algorithm-introduction)
|
||||
- [Algorithm Principle](#algorithm-principle)
|
||||
- [Search Space and Search Policy](#search-space-and-search-policy)
|
||||
- [Dataset](#dataset)
|
||||
- [Requirements](#requirements)
|
||||
- [Hardware (Ascend)](#hardware-ascend)
|
||||
- [Framework](#framework)
|
||||
- [For more information, please check the resources below](#for-more-information-please-check-the-resources-below)
|
||||
- [Script Description](#script-description)
|
||||
- [Scripts and Sample Code](#scripts-and-sample-code)
|
||||
- [Script Parameter](#script-parameter)
|
||||
- [Training Process](#training-process)
|
||||
- [For training](#for-training)
|
||||
- [Evaluation](#evaluation)
|
||||
- [Evaluation Process](#evaluation-process)
|
||||
- [Evaluation Result](#evaluation-result)
|
||||
- [Performance](#performance)
|
||||
- [Inference Performance](#inference-performance)
|
||||
- [ModeZoo Homepage](#modezoo-homepage)
|
||||
|
||||
## Algorithm Introduction
|
||||
|
||||
SR-EA is a module that uses the evolutionary algorithm (EA) to search for the image super-resolution (SR) network architecture. EA is a common automatic network architecture search method (NAS). The search process is as follows:
|
||||
|
||||
1. Sampling a series of models (usually random), and perform incomplete training (for example, reduce the number of iterations or training samples) on each model.
|
||||
2. Calculating a Pareto front (pareto front) of all currently generated models, generating an evolutionary model based on the Pareto front, and performing incomplete training on each model;
|
||||
3. Repeat step 2 until the specified maximum iterations are reached or the specified performance is achieved.
|
||||
|
||||
## Algorithm Principle
|
||||
|
||||
SR-EA provides two series of network architectures: modified SRResNet (baseline) and CCRN-NAS (from Noah's Ark ). The following figure shows the structure of Modified SRResNet:
|
||||
|
||||

|
||||
|
||||
SR-EA provides two architecture search policies ( random search & brute force search ), which focus on searching for the number of blocks and channels in the architecture.
|
||||
CCRN-NAS is a network architecture dedicated to lightweight networks. The CCRN-NAS consists of three types of blocks:
|
||||
|
||||
1. Residual block whose kernel size is 2;
|
||||
2. Residual block whose kernel size is 3;
|
||||
3. Channel Acquisition Block (CIB): consists of the two modules in sequence. Each module combines the above two outputs in the channel dimension. Therefore, the number of channels is doubled after the CIB.
|
||||
|
||||
Pipeline provides a sample for CCRN-NAS architecture search. It searches for the combination of the three modules to optimize the network architecture.
|
||||
|
||||
## Search Space and Search Policy
|
||||
|
||||
The search space of the modified SRResNet includes the number of blocks and channels. We provide two search methods: random search (RS) and brute force (BF). In the two search methods, users need to define the range of the block number and the channel number for each convolution layer. RS generates model randomly from these range until the number of models reaches max_count. On the other size, BF will train all selected models.
|
||||
|
||||
The search space of CCRN-NAS is a combination of three types of blocks:
|
||||
|
||||
1. Random search: The number of residual blocks and the number of CIBs are selected based on user-defined conditions. In the residual block, the ratio of convolution layer with kernel size 2 is randomly generated between [0,1]. The sampling process generates a common residual block and randomly inserts CIB into the residual block.
|
||||
|
||||
2. Evolution search: Models on Pareto front are selected for modification each time. Following operations are allowed:
|
||||
– Change the kernel size of a random residual block from 2 to 3 or from 3 to 2.
|
||||
– A residual block is added to the random number of layers, and the kernel size is randomly generated in 2 and 3.
|
||||
|
||||
## Dataset
|
||||
|
||||
The benchmark datasets can be downloaded as follows:
|
||||
|
||||
[DIV2K](https://cv.snu.ac.kr/research/EDSR/DIV2K.tar).
|
||||
|
||||
## Requirements
|
||||
|
||||
### Hardware (Ascend)
|
||||
|
||||
> Prepare hardware environment with Ascend.
|
||||
|
||||
### Framework
|
||||
|
||||
> [MindSpore](https://www.mindspore.cn/install/en)
|
||||
|
||||
### For more information, please check the resources below
|
||||
|
||||
[MindSpore Tutorials](https://www.mindspore.cn/tutorials/en/r1.3/index.html)
|
||||
[MindSpore Python API](https://www.mindspore.cn/docs/api/en/r1.3/index.html)
|
||||
|
||||
## Script Description
|
||||
|
||||
### Scripts and Sample Code
|
||||
|
||||
```bash
|
||||
sr_ea
|
||||
├── eval.py # inference entry
|
||||
├── train.py # pre-training entry
|
||||
├── image
|
||||
│ └── sr_ea_SRResNet.png # the illustration of sr_ea network
|
||||
├── readme.md # Readme
|
||||
├── scripts
|
||||
│ ├── run_distributed.sh # pre-training script for all tasks
|
||||
└── src
|
||||
├── sr_ea.yml # options/hyper-parameters of sr_ea
|
||||
└── sr_ea_distributed.yml # options/hyper-parameters of sr_ea
|
||||
|
||||
```
|
||||
|
||||
### Script Parameter
|
||||
|
||||
> For details about hyperparameters, see src/sr_ea.yml.
|
||||
|
||||
## Training Process
|
||||
|
||||
### For training
|
||||
|
||||
```bash
|
||||
python3 train.py
|
||||
```
|
||||
|
||||
> Or one can run following script for all tasks.
|
||||
|
||||
```bash
|
||||
sh scripts/run_distributed.sh [RANK_TABLE_FILE]
|
||||
```
|
||||
|
||||
## Evaluation
|
||||
|
||||
### Evaluation Process
|
||||
|
||||
> Inference example:
|
||||
|
||||
Modify src/eval.yml:
|
||||
|
||||
```bash
|
||||
models_folder: [CHECKPOINT_PATH]
|
||||
```
|
||||
|
||||
```bash
|
||||
python3 eval.py
|
||||
```
|
||||
|
||||
### Evaluation Result
|
||||
|
||||
The result are evaluated by the value of PSNR, and the format is as following.
|
||||
|
||||
```bash
|
||||
INFO finished host evaluation, id: 44, performance: {'PSNR': 43.35796722215399, 'latency': 0.5015704035758972}
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
### Inference Performance
|
||||
|
||||
The Results on super resolution tasks are listed as below.
|
||||
|
||||
| Parameters | Ascend |
|
||||
| -------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| Model Version | V1 |
|
||||
| Resource | CentOs 8.2; Ascend 910; CPU 2.60GHz, 192cores; Memory 755G |
|
||||
| uploaded Date | 08/26/2021 (month/day/year) |
|
||||
| MindSpore Version | 1.2.0 |
|
||||
| Dataset | DIV2K Dataset |
|
||||
| Training Parameters | epoch=20000, batch_size = 50 |
|
||||
| Optimizer | Adam |
|
||||
| Loss Function | L1Loss |
|
||||
| Output | super resolution image |
|
||||
| PSNR | 43.35 |
|
||||
| Scripts | [sr_ea script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/research/cv/sr_ea) |
|
||||
|
||||
## ModeZoo Homepage
|
||||
|
||||
Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""eval script"""
|
||||
import vega
|
||||
|
||||
if __name__ == '__main__':
|
||||
vega.run('./src/eval.yml')
|
||||
vega.set_backend('mindspore', 'NPU')
|
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
|
@ -0,0 +1 @@
|
|||
noah-vega
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
ulimit -u unlimited
|
||||
export DEVICE_NUM=8
|
||||
export RANK_SIZE=8
|
||||
|
||||
if [ $# != 1 ]
|
||||
then
|
||||
echo "Usage: sh run_distribution.sh [RANK_TABLE_FILE]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $1 ]
|
||||
then
|
||||
echo "error: RANK_TABLE_FILE=$1 is not a file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RANK_TABLE_FILE=$(realpath $1)
|
||||
export RANK_TABLE_FILE
|
||||
|
||||
python3 -m vega.tools.run_pipeline ../src/sr_ea_distributed.yml -b m -d NPU \
|
||||
> train.log 2>&1 &
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
ulimit -u unlimited
|
||||
export DEVICE_NUM=1
|
||||
export RANK_SIZE=1
|
||||
|
||||
if [ $# != 0 ]
|
||||
then
|
||||
echo "Usage: sh run_standalone.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 -m vega.tools.run_pipeline ../src/sr_ea.yml -b m -d NPU \
|
||||
> train.log 2>&1 &
|
|
@ -0,0 +1,59 @@
|
|||
general:
|
||||
backend: mindspore
|
||||
|
||||
pipeline: [eval]
|
||||
|
||||
eval:
|
||||
pipe_step:
|
||||
type: TrainPipeStep
|
||||
models_folder: ~
|
||||
dataset:
|
||||
type: DIV2K
|
||||
common:
|
||||
value_div: 255.0
|
||||
train:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_train/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
crop: 64 # crop size of lr image
|
||||
hflip: true # flip image horizontally
|
||||
vflip: true # flip image vertically
|
||||
rot90: true # flip image diagonally
|
||||
shuffle: true
|
||||
num_workers: 2
|
||||
batch_size: 16
|
||||
pin_memory: false
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_valid/lr
|
||||
upscale: 2
|
||||
crop: 64
|
||||
pin_memory: false
|
||||
trainer:
|
||||
with_train: False
|
||||
type: Trainer
|
||||
epochs: 400
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0004
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [100, 200]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
calc_params_each_epoch: True
|
||||
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
load_pkl: False
|
|
@ -0,0 +1,195 @@
|
|||
general:
|
||||
backend: mindspore
|
||||
|
||||
|
||||
pipeline: [random, mutate, fully_train, benchmark_DIV2K, benchmark_Set5, benchmark_Set14, benchmark_BSDS100]
|
||||
|
||||
|
||||
random:
|
||||
pipe_step:
|
||||
type: SearchPipeStep
|
||||
|
||||
dataset:
|
||||
type: DIV2K
|
||||
common:
|
||||
value_div: 255.0
|
||||
train:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_train/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
crop: 64 # crop size of lr image
|
||||
hflip: true # flip image horizontally
|
||||
vflip: true # flip image vertically
|
||||
rot90: true # flip image diagonally
|
||||
shuffle: true
|
||||
num_workers: 2
|
||||
batch_size: 16
|
||||
pin_memory: false
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_valid/lr
|
||||
upscale: 2
|
||||
crop: 64
|
||||
pin_memory: false
|
||||
search_space:
|
||||
type: SearchSpace
|
||||
modules: ['custom']
|
||||
custom:
|
||||
type: MtMSR
|
||||
in_channel: 3
|
||||
out_channel: 3
|
||||
upscale: 2
|
||||
rgb_mean: [0.4040, 0.4371, 0.4488]
|
||||
candidates: [res2, res3]
|
||||
block_range: [10, 80]
|
||||
cib_range: [3, 4]
|
||||
|
||||
search_algorithm:
|
||||
type: SRRandom
|
||||
codec: SRCodec
|
||||
policy:
|
||||
num_sample: 1000
|
||||
|
||||
trainer:
|
||||
type: Trainer
|
||||
epochs: 400
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0004
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [100, 200]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
calc_params_each_epoch: True
|
||||
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
load_pkl: False
|
||||
|
||||
|
||||
mutate:
|
||||
pipe_step:
|
||||
type: SearchPipeStep
|
||||
|
||||
dataset:
|
||||
ref: random.dataset
|
||||
|
||||
search_space:
|
||||
type: SearchSpace
|
||||
ref: random.search_space
|
||||
|
||||
search_algorithm:
|
||||
type: SRMutate
|
||||
codec: SRCodec
|
||||
policy:
|
||||
num_mutate: 3
|
||||
num_sample: 1000
|
||||
|
||||
trainer:
|
||||
ref: random.trainer
|
||||
epochs: 100
|
||||
save_model_desc: True
|
||||
|
||||
|
||||
fully_train:
|
||||
pipe_step:
|
||||
type: TrainPipeStep
|
||||
models_folder: "{local_base_path}/output/mutate/"
|
||||
dataset:
|
||||
ref: random.dataset
|
||||
train:
|
||||
batch_size: 50
|
||||
|
||||
search_space:
|
||||
ref: random.search_space
|
||||
|
||||
trainer:
|
||||
type: Trainer
|
||||
seed: 0
|
||||
epochs: 20000
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0002
|
||||
lr_scheduler:
|
||||
type: StepLR
|
||||
params:
|
||||
step_size: 4000
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
|
||||
|
||||
benchmark_DIV2K:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
type: DIV2K
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
|
||||
benchmark_Set5:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set5
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set5/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set5/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_Set14:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set14
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set14/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set14/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_BSDS100:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: BSDS100
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/BSDS100/hr
|
||||
root_LR: /cache/datasets/DIV2K/BSDS100/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
|
@ -0,0 +1,197 @@
|
|||
general:
|
||||
backend: mindspore
|
||||
parallel_search: True
|
||||
parallel_fully_train: True
|
||||
|
||||
|
||||
pipeline: [random, mutate, fully_train, benchmark_DIV2K, benchmark_Set5, benchmark_Set14, benchmark_BSDS100]
|
||||
|
||||
|
||||
random:
|
||||
pipe_step:
|
||||
type: SearchPipeStep
|
||||
|
||||
dataset:
|
||||
type: DIV2K
|
||||
common:
|
||||
value_div: 255.0
|
||||
train:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_train/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
crop: 64 # crop size of lr image
|
||||
hflip: true # flip image horizontally
|
||||
vflip: true # flip image vertically
|
||||
rot90: true # flip image diagonally
|
||||
shuffle: true
|
||||
num_workers: 2
|
||||
batch_size: 16
|
||||
pin_memory: false
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_valid/lr
|
||||
upscale: 2
|
||||
crop: 64
|
||||
pin_memory: false
|
||||
search_space:
|
||||
type: SearchSpace
|
||||
modules: ['custom']
|
||||
custom:
|
||||
type: MtMSR
|
||||
in_channel: 3
|
||||
out_channel: 3
|
||||
upscale: 2
|
||||
rgb_mean: [0.4040, 0.4371, 0.4488]
|
||||
candidates: [res2, res3]
|
||||
block_range: [10, 80]
|
||||
cib_range: [3, 4]
|
||||
|
||||
search_algorithm:
|
||||
type: SRRandom
|
||||
codec: SRCodec
|
||||
policy:
|
||||
num_sample: 1000
|
||||
|
||||
trainer:
|
||||
type: Trainer
|
||||
epochs: 400
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0004
|
||||
lr_scheduler:
|
||||
type: MultiStepLR
|
||||
params:
|
||||
milestones: [100, 200]
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
calc_params_each_epoch: True
|
||||
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
load_pkl: False
|
||||
|
||||
|
||||
mutate:
|
||||
pipe_step:
|
||||
type: SearchPipeStep
|
||||
|
||||
dataset:
|
||||
ref: random.dataset
|
||||
|
||||
search_space:
|
||||
type: SearchSpace
|
||||
ref: random.search_space
|
||||
|
||||
search_algorithm:
|
||||
type: SRMutate
|
||||
codec: SRCodec
|
||||
policy:
|
||||
num_mutate: 3
|
||||
num_sample: 1000
|
||||
|
||||
trainer:
|
||||
ref: random.trainer
|
||||
epochs: 100
|
||||
save_model_desc: True
|
||||
|
||||
|
||||
fully_train:
|
||||
pipe_step:
|
||||
type: TrainPipeStep
|
||||
models_folder: "{local_base_path}/output/mutate/"
|
||||
dataset:
|
||||
ref: random.dataset
|
||||
train:
|
||||
batch_size: 50
|
||||
|
||||
search_space:
|
||||
ref: random.search_space
|
||||
|
||||
trainer:
|
||||
type: Trainer
|
||||
seed: 0
|
||||
epochs: 20000
|
||||
optimizer:
|
||||
type: Adam
|
||||
params:
|
||||
lr: 0.0002
|
||||
lr_scheduler:
|
||||
type: StepLR
|
||||
params:
|
||||
step_size: 4000
|
||||
gamma: 0.5
|
||||
loss:
|
||||
type: L1Loss
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
|
||||
|
||||
benchmark_DIV2K:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
type: DIV2K
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/div2k_valid/hr
|
||||
root_LR: /cache/datasets/DIV2K/div2k_train/lr
|
||||
upscale: 2
|
||||
evaluator:
|
||||
type: Evaluator
|
||||
host_evaluator:
|
||||
type: HostEvaluator
|
||||
metric:
|
||||
type: PSNR
|
||||
params:
|
||||
scale: 2
|
||||
|
||||
benchmark_Set5:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set5
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set5/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set5/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_Set14:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: Set14
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/Set14/hr
|
||||
root_LR: /cache/datasets/DIV2K/Set14/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
||||
|
||||
benchmark_BSDS100:
|
||||
pipe_step:
|
||||
type: BenchmarkPipeStep
|
||||
models_folder: "{local_base_path}/output/fully_train/"
|
||||
dataset:
|
||||
ref: benchmark_DIV2K.dataset
|
||||
type: BSDS100
|
||||
test:
|
||||
root_HR: /cache/datasets/DIV2K/BSDS100/hr
|
||||
root_LR: /cache/datasets/DIV2K/BSDS100/lr
|
||||
evaluator:
|
||||
ref: benchmark_DIV2K.evaluator
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""train"""
|
||||
import vega
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
vega.run('./src/sr_ea.yml')
|
||||
vega.set_backend('mindspore', 'NPU')
|
Loading…
Reference in New Issue