108 Star 865 Fork 1.5K

MindSpore/models

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.gitee
.github
.ipynb_checkpoints
.jenkins
benchmark/ascend
community
how_to_contribute
official
research
3d/DeepLM
audio
cv
3D_DenseNet
3dcnn
ADNet
APDrawingGAN
AVA_cifar
AVA_hpa
AdaBin
AdderNGD
AdderQuant
Alexnet
AlignedReID++
AlignedReID
AlphaPose
ArbitraryStyleTransfer
ArtTrack
AttGAN
AttentionCluster
Auto-DeepLab
AutoSlim
BMN
BiMLP
C3D
CBAM
CFDT
CGAN
CLIFF
CMT
CSNL
CTSDG
CascadeRCNN
Cnet
ConstrainedBayesian
DBPN
DDAG
DDM
DDRNet
DRNet
DecoMR
DeepID
Deepsort
DeiT
DepthNet
DnCNN
DynamicQuant
E-NET
ECENet
EF-ENAS
EGnet
ESRGAN
EfficientDet_d0
FCANet
FCN8s
FCOS
FDA-BNN
FSAF
FaceAttribute
FaceDetection
FaceNet
FaceQualityAssessment
FaceRecognition
FaceRecognitionForTracking
Focus-DETR
FreeAnchor
GENet_Res50
GMMBN
GhostSR
Gold_YOLO
GridRCNN
HDR-Transformer
HMR
HRNetV2
HRNetW48_cls
HRNetW48_seg
HiFaceGAN
HireMLP
HourNAS
I3D
ICNet
IPT
IRN
ISyNet
Inception-v2
IndexNet
Instaboost
IntegralNeuralNetworks
JDE
LEO
LearningToSeeInTheDark
LightCNN
MAML
MCNN
MGN
MIMO-UNet
MODNet
MTCNN
MVD
ManiDP
MaskedFaceRecognition
NFNet
Neighbor2Neighbor
Non_local
OSVOS
OctSqueeze
PAGENet
PAMTRI
PDarts
PGAN
PSPNet
PTQ4SR
PVAnet
PWCNet
PaDiM
PatchCore
Pix2Pix
Pix2PixHD
PoseNet
ProtoNet
PyramidBox
RAOD
RCAN
RDN
REDNet30
RNA
ReIDStrongBaseline
RefSR-NeRF
RefineDet
RefineNet
RepVGG
ResNeSt50
ResNeXt
ResidualAttentionNet
S-GhostNet
SDNet
SE-Net
SE_ResNeXt50
SPADE
SPC-Net
SPPNet
SRGAN
SSIM-AE
STGAN
STPM
Segformer
SemanticHumanMatting
SiamFC
SinGAN
SpineNet
Spnas
StackedHourglass
StarGAN
StyTr-2
TCN
TNT
TinySAM
TokenFusion
Twins
U-GAT-IT
UNet3+
Unet3d
VehicleNet
ViG
WGAN_GP
Yolact++
adelaide_ea
advanced_east
aecrnet
ats
augvit
autoaugment
beit
brdnet
cait
cct
cdp
centerface
centernet
centernet_det
centernet_resnet101
centernet_resnet50_v1
cmr
cnn_direction_model
cnnctc
conformer
convmixer
convnext
crnn_seq2seq_ocr
csd
cspdarknet53
darknet53
dcgan
dcrnn
delf
dem
densenet
detr
dgcnet_res101
dlinknet
dncnn
dnet_nas
dpn
east
ecolite
efficientnet-b0
eppmvsnet
erfnet
esr_ea
image
scripts
src
README.md
eval.py
requirements.txt
train.py
essay-recogination
faceboxes
fairmot
faster_rcnn_dcn
faster_rcnn_ssod
fastflow
fastscnn
fishnet99
flownet2
foveabox
frustum-pointnet
gan
ghostnet
ghostnet_d
ghostnet_quant
ghostnetv2
glore_res
googlenet
guided_anchoring
hardnet
hed
hlg
ibnnet
inception_resnet_v2
ivpf
lenet
lerf
libra-rcnn
lite-hrnet
llnet
lresnet100e_ir
m2det
meta-baseline
metric_learn
midas
mifnet
mnasnet
mobilenetV3_small_x1_0
mobilenetv3_large
ms_rcnn
nas-fpn
nasnet
nima
nima_vgg16
nnUNet
ntsnet
osnet
pcb
pcb_rpp
pnasnet
pointpillars
pointtransformer
predrnn++
proxylessnas
psenet
r2plus1d
ras
rbpn
rcnn
relationnet
renas
repvgg
res2net
res2net_deeplabv3
res2net_faster_rcnn
res2net_yolov3
resnet3d
resnet50_adv_pruning
resnet50_bam
resnetv2
resnetv2_50_frn
resnext152_64x4d
retinaface
retinanet_resnet101
retinanet_resnet152
rfcn
se_resnext50
siamRPN
simclr
simple_baselines
simple_pose
single_path_nas
sknet
slowfast
snn_mlp
sphereface
squeezenet
squeezenet1_1
sr_ea
srcnn
ssc_resnet50
ssd_ghostnet
ssd_inception_v2
ssd_inceptionv2
ssd_mobilenetV2
ssd_mobilenetV2_FPNlite
ssd_resnet34
ssd_resnet50
ssd_resnet_34
stgcn
stnet
swenet
t2t-vit
tall
textfusenet
tgcn
tinydarknet
tinynet
tnt
tracktor++
tracktor
trn
tsm
tsn
u2net
uni-uvpt
unisiam
vanillanet
vit_base
vnet
warpctc
wave_mlp
wdsr
wideresnet
yolov3_resnet18
yolov3_tiny
gflownets
gnn
hpc
l2o/hem-learning-to-cut
mm
nerf
nlp
recommend
rl
.gitkeep
README.md
README_CN.md
__init__.py
utils
.clang-format
.gitignore
CONTRIBUTING.md
CONTRIBUTING_CN.md
LICENSE
OWNERS
README.md
README_CN.md
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Contents

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.

[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.

arch

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:

block

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:

['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.

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.

After downloaded the correspond dataset to the target place, You can configure and use the dataset separately for train and test.

Dataset configuration parameters in esr_ea/esr_ea.yml:

nas:
    dataset:
        type: DIV2K
        train:
            root_HR: /cache/datasets/DIV2K/div2k_train/hr # Directory where the HR image is located
            root_LR: /cache/datasets/DIV2K/div2k_train/lr # Directory where the LR image is located
            upscale: 2                                    # Up scale
            crop: 64                                      # crop size of lr image
            hflip: true                                   # flip image horizontally
            vflip: true                                   # flip image vertically
            rot90: true                                   # flip image diagonally
            shuffle: true                                 # shuffle
            batch_size: 16                                # batch size
            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

Requirements

Hardware (Ascend)

Prepare hardware environment with Ascend.

Framework

MindSpore

For more information, please check the resources below

MindSpore Tutorials MindSpore Python API

Script Description

Scripts and Sample Code

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_standalone.sh # shell script for standalone train on ascend
│   ├── run_distributed.sh # shell script for distributed train on ascend
└── src
    └── esr_ea.yml # options/hyper-parameters of esr_ea

Script Parameter

For details about hyperparameters, see src/esr_ea.yml.

Training Process

For training

  • Standalone Ascend Training:
sh scripts/run_standalone.sh
  • Distributed Ascend Training:
sh scripts/run_distributed.sh  [RANK_TABLE_FILE]

For distributed training, a hccl configuration file with JSON format needs to be created in advance.

Please follow the instructions in the link below:

https://gitee.com/mindspore/models/tree/master/utils/hccl_tools. $RANK_TABLE_FILE is needed when you are running a distribute task on ascend.

Or one can run following script for all tasks.

python3 train.py

Evaluation

Evaluation Process

Inference example:

Modify src/eval.yml:

models_folder: [CHECKPOINT_PATH]
python3 eval.py

Evaluation Result

The result are evaluated by the value of PSNR, and the format is as following.

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

ModeZoo Homepage

Please check the official homepage.

FAQ

  • this network doesn't support PYNATIVE mode.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mindspore/models.git
git@gitee.com:mindspore/models.git
mindspore
models
models
master

搜索帮助