From 49bf3d3f95d4f86d9109c068c47747d44e989cdc Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Fri, 11 Sep 2020 14:17:12 +0000 Subject: [PATCH] add resnest metrics --- README.md | 4 ++-- docs/en/models/ResNeSt_RegNet_en.md | 4 ++-- docs/zh_CN/models/ResNeSt_RegNet.md | 4 ++-- ppcls/modeling/architectures/resnest.py | 19 ++++++------------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index b480fadb..5f1c9234 100644 --- a/README.md +++ b/README.md @@ -286,8 +286,8 @@ ResNeSt与RegNet系列模型的精度、速度指标如下表所示,更多关 | 模型 | Top-1 Acc | Top-5 Acc | time(ms)
bs=1 | time(ms)
bs=4 | Flops(G) | Params(M) | 下载地址 | |------------------------|-----------|-----------|------------------|------------------|----------|-----------|------------------------------------------------------------------------------------------------------| -| ResNeSt50_
fast_1s1x64d | 0.8035 | 0.9528 | - | - | 8.68 | 26.3 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeSt50_fast_1s1x64d_pretrained.pdparams) | -| ResNeSt50 | 0.8102 | 0.9542 | - | - | 10.78 | 27.5 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeSt50_pretrained.pdparams) | +| ResNeSt50_
fast_1s1x64d | 0.8035 | 0.9528 | 3.45405 | 8.72680 | 8.68 | 26.3 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeSt50_fast_1s1x64d_pretrained.pdparams) | +| ResNeSt50 | 0.8102 | 0.9542 | 6.69042 | 8.01664 | 10.78 | 27.5 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeSt50_pretrained.pdparams) | | RegNetX_4GF | 0.785 | 0.9416 | 6.46478 | 11.19862 | 8 | 22.1 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/RegNetX_4GF_pretrained.pdparams) | diff --git a/docs/en/models/ResNeSt_RegNet_en.md b/docs/en/models/ResNeSt_RegNet_en.md index 006ffd3b..959597a8 100644 --- a/docs/en/models/ResNeSt_RegNet_en.md +++ b/docs/en/models/ResNeSt_RegNet_en.md @@ -17,6 +17,6 @@ RegNet was proposed in 2020 by Facebook to deepen the concept of design space. B | Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | |--------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| -| ResNeSt50_fast_1s1x64d | 224 | 256 | - | - | - | - | - | - | -| ResNeSt50 | 224 | 256 | - | - | - | - | - | - | +| ResNeSt50_fast_1s1x64d | 224 | 256 | 3.46466 | 5.56647 | 9.11848 | 3.45405 | 8.72680 | 15.48710 | +| ResNeSt50 | 224 | 256 | 7.05851 | 8.97676 | 13.34704 | 6.16248 | 12.0633 | 21.49936 | | RegNetX_4GF | 224 | 256 | 6.69042 | 8.01664 | 11.60608 | 6.46478 | 11.19862 | 16.89089 | diff --git a/docs/zh_CN/models/ResNeSt_RegNet.md b/docs/zh_CN/models/ResNeSt_RegNet.md index 1960237b..a995347b 100644 --- a/docs/zh_CN/models/ResNeSt_RegNet.md +++ b/docs/zh_CN/models/ResNeSt_RegNet.md @@ -20,6 +20,6 @@ RegNet是由facebook于2020年提出,旨在深化设计空间理念的概念 | Models | Crop Size | Resize Short Size | FP16
Batch Size=1
(ms) | FP16
Batch Size=4
(ms) | FP16
Batch Size=8
(ms) | FP32
Batch Size=1
(ms) | FP32
Batch Size=4
(ms) | FP32
Batch Size=8
(ms) | |--------------------|-----------|-------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------|------------------------------| -| ResNeSt50_fast_1s1x64d | 224 | 256 | - | - | - | - | - | - | -| ResNeSt50 | 224 | 256 | - | - | - | - | - | - | +| ResNeSt50_fast_1s1x64d | 224 | 256 | 3.46466 | 5.56647 | 9.11848 | 3.45405 | 8.72680 | 15.48710 | +| ResNeSt50 | 224 | 256 | 7.05851 | 8.97676 | 13.34704 | 6.16248 | 12.0633 | 21.49936 | | RegNetX_4GF | 224 | 256 | 6.69042 | 8.01664 | 11.60608 | 6.46478 | 11.19862 | 16.89089 | diff --git a/ppcls/modeling/architectures/resnest.py b/ppcls/modeling/architectures/resnest.py index d5f1933b..e98e8bdc 100644 --- a/ppcls/modeling/architectures/resnest.py +++ b/ppcls/modeling/architectures/resnest.py @@ -104,11 +104,7 @@ class ResNeSt(): is_first=False, name="layer1") x = self.resnest_layer( - x=x, - planes=128, - blocks=self.layers[1], - stride=2, - name="layer2") + x=x, planes=128, blocks=self.layers[1], stride=2, name="layer2") if self.dilated or self.dilation == 4: x = self.resnest_layer( x=x, @@ -152,10 +148,8 @@ class ResNeSt(): blocks=self.layers[3], stride=2, name="layer4") - x = fluid.layers.pool2d( - input=x, pool_type="avg", global_pooling=True) - x = fluid.layers.dropout( - x=x, dropout_prob=self.final_drop) + x = fluid.layers.pool2d(input=x, pool_type="avg", global_pooling=True) + x = fluid.layers.dropout(x=x, dropout_prob=self.final_drop) stdv = 1.0 / math.sqrt(x.shape[1] * 1.0) x = fluid.layers.fc( input=x, @@ -266,8 +260,7 @@ class ResNeSt(): param_attr=ParamAttr( name=name + "_splat_weights", initializer=MSRA()), bias_attr=False) - atten = self.rsoftmax( - x=atten, radix=radix, cardinality=groups) + atten = self.rsoftmax(x=atten, radix=radix, cardinality=groups) atten = fluid.layers.reshape(x=atten, shape=[-1, atten.shape[1], 1, 1]) if radix > 1: @@ -275,10 +268,10 @@ class ResNeSt(): input=atten, num_or_sections=radix, dim=1) out = fluid.layers.sum([ fluid.layers.elementwise_mul( - x=att, y=split) for (att, split) in zip(attens, splited) + x=split, y=att) for (att, split) in zip(attens, splited) ]) else: - out = fluid.layers.elementwise_mul(atten, x) + out = fluid.layers.elementwise_mul(x, atten) return out def bottleneck(self, -- GitLab