Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
1ecf8334
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 1 年 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1ecf8334
编写于
12月 06, 2020
作者:
L
littletomatodonkey
提交者:
GitHub
12月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix pred (#450)
* fix pred * fix resnest * fix hrnet se * fix se for export
上级
0df5ba63
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
26 deletion
+23
-26
ppcls/modeling/architectures/ghostnet.py
ppcls/modeling/architectures/ghostnet.py
+2
-3
ppcls/modeling/architectures/hrnet.py
ppcls/modeling/architectures/hrnet.py
+6
-7
ppcls/modeling/architectures/resnest.py
ppcls/modeling/architectures/resnest.py
+3
-2
ppcls/modeling/architectures/se_resnet_vd.py
ppcls/modeling/architectures/se_resnet_vd.py
+2
-3
ppcls/modeling/architectures/se_resnext.py
ppcls/modeling/architectures/se_resnext.py
+2
-3
ppcls/modeling/architectures/se_resnext_vd.py
ppcls/modeling/architectures/se_resnext_vd.py
+2
-3
tools/infer/predict.py
tools/infer/predict.py
+6
-5
未找到文件。
ppcls/modeling/architectures/ghostnet.py
浏览文件 @
1ecf8334
...
...
@@ -83,13 +83,12 @@ class SEBlock(nn.Layer):
def
forward
(
self
,
inputs
):
pool
=
self
.
pool2d_gap
(
inputs
)
pool
=
paddle
.
reshape
(
pool
,
shape
=
[
-
1
,
self
.
_num_channels
])
pool
=
paddle
.
squeeze
(
pool
,
axis
=
[
2
,
3
])
squeeze
=
self
.
squeeze
(
pool
)
squeeze
=
F
.
relu
(
squeeze
)
excitation
=
self
.
excitation
(
squeeze
)
excitation
=
paddle
.
clip
(
x
=
excitation
,
min
=
0
,
max
=
1
)
excitation
=
paddle
.
reshape
(
excitation
,
shape
=
[
-
1
,
self
.
_num_channels
,
1
,
1
])
excitation
=
paddle
.
unsqueeze
(
excitation
,
axis
=
[
2
,
3
])
out
=
inputs
*
excitation
return
out
...
...
ppcls/modeling/architectures/hrnet.py
浏览文件 @
1ecf8334
...
...
@@ -322,8 +322,7 @@ class SELayer(nn.Layer):
self
.
squeeze
=
Linear
(
num_channels
,
med_ch
,
act
=
"relu"
,
param_attr
=
ParamAttr
(
weight_attr
=
ParamAttr
(
initializer
=
Uniform
(
-
stdv
,
stdv
),
name
=
name
+
"_sqz_weights"
),
bias_attr
=
ParamAttr
(
name
=
name
+
'_sqz_offset'
))
...
...
@@ -331,18 +330,18 @@ class SELayer(nn.Layer):
self
.
excitation
=
Linear
(
med_ch
,
num_filters
,
act
=
"sigmoid"
,
param_attr
=
ParamAttr
(
weight_attr
=
ParamAttr
(
initializer
=
Uniform
(
-
stdv
,
stdv
),
name
=
name
+
"_exc_weights"
),
bias_attr
=
ParamAttr
(
name
=
name
+
'_exc_offset'
))
def
forward
(
self
,
input
):
pool
=
self
.
pool2d_gap
(
input
)
pool
=
paddle
.
reshape
(
pool
,
shape
=
[
-
1
,
self
.
_num_channels
])
pool
=
paddle
.
squeeze
(
pool
,
axis
=
[
2
,
3
])
squeeze
=
self
.
squeeze
(
pool
)
squeeze
=
F
.
relu
(
squeeze
)
excitation
=
self
.
excitation
(
squeeze
)
excitation
=
paddle
.
reshape
(
excitation
,
shape
=
[
-
1
,
self
.
_num_channels
,
1
,
1
])
excitation
=
F
.
sigmoid
(
excitation
)
excitation
=
paddle
.
unsqueeze
(
excitation
,
axis
=
[
2
,
3
])
out
=
input
*
excitation
return
out
...
...
ppcls/modeling/architectures/resnest.py
浏览文件 @
1ecf8334
...
...
@@ -85,7 +85,8 @@ class rSoftmax(nn.Layer):
x
=
paddle
.
reshape
(
x
=
x
,
shape
=
[
batch
,
cardinality
,
radix
,
int
(
r
*
h
*
w
/
cardinality
/
radix
)
batch
,
cardinality
,
radix
,
int
(
r
*
h
*
w
/
cardinality
/
radix
)
])
x
=
paddle
.
transpose
(
x
=
x
,
perm
=
[
0
,
2
,
1
,
3
])
x
=
nn
.
functional
.
softmax
(
x
,
axis
=
1
)
...
...
@@ -164,7 +165,7 @@ class SplatConv(nn.Layer):
atten
=
self
.
conv3
(
gap
)
atten
=
self
.
rsoftmax
(
atten
)
atten
=
paddle
.
reshape
(
x
=
atten
,
shape
=
[
-
1
,
atten
.
shape
[
1
],
1
,
1
])
atten
=
paddle
.
unsqueeze
(
x
=
atten
,
axis
=
[
2
,
3
])
if
self
.
radix
>
1
:
attens
=
paddle
.
split
(
atten
,
num_or_sections
=
self
.
radix
,
axis
=
1
)
...
...
ppcls/modeling/architectures/se_resnet_vd.py
浏览文件 @
1ecf8334
...
...
@@ -223,13 +223,12 @@ class SELayer(nn.Layer):
def
forward
(
self
,
input
):
pool
=
self
.
pool2d_gap
(
input
)
pool
=
paddle
.
reshape
(
pool
,
shape
=
[
-
1
,
self
.
_num_channels
])
pool
=
paddle
.
squeeze
(
pool
,
axis
=
[
2
,
3
])
squeeze
=
self
.
squeeze
(
pool
)
squeeze
=
F
.
relu
(
squeeze
)
excitation
=
self
.
excitation
(
squeeze
)
excitation
=
F
.
sigmoid
(
excitation
)
excitation
=
paddle
.
reshape
(
excitation
,
shape
=
[
-
1
,
self
.
_num_channels
,
1
,
1
])
excitation
=
paddle
.
unsqueeze
(
excitation
,
axis
=
[
2
,
3
])
out
=
input
*
excitation
return
out
...
...
ppcls/modeling/architectures/se_resnext.py
浏览文件 @
1ecf8334
...
...
@@ -157,13 +157,12 @@ class SELayer(nn.Layer):
def
forward
(
self
,
input
):
pool
=
self
.
pool2d_gap
(
input
)
pool
=
paddle
.
reshape
(
pool
,
shape
=
[
-
1
,
self
.
_num_channels
])
pool
=
paddle
.
squeeze
(
pool
,
axis
=
[
2
,
3
])
squeeze
=
self
.
squeeze
(
pool
)
squeeze
=
self
.
relu
(
squeeze
)
excitation
=
self
.
excitation
(
squeeze
)
excitation
=
self
.
sigmoid
(
excitation
)
excitation
=
paddle
.
reshape
(
excitation
,
shape
=
[
-
1
,
self
.
_num_channels
,
1
,
1
])
excitation
=
paddle
.
unsqueeze
(
excitation
,
axis
=
[
2
,
3
])
out
=
input
*
excitation
return
out
...
...
ppcls/modeling/architectures/se_resnext_vd.py
浏览文件 @
1ecf8334
...
...
@@ -164,13 +164,12 @@ class SELayer(nn.Layer):
def
forward
(
self
,
input
):
pool
=
self
.
pool2d_gap
(
input
)
pool
=
paddle
.
reshape
(
pool
,
shape
=
[
-
1
,
self
.
_num_channels
])
pool
=
paddle
.
squeeze
(
pool
,
axis
=
[
2
,
3
])
squeeze
=
self
.
squeeze
(
pool
)
squeeze
=
self
.
relu
(
squeeze
)
excitation
=
self
.
excitation
(
squeeze
)
excitation
=
self
.
sigmoid
(
excitation
)
excitation
=
paddle
.
reshape
(
excitation
,
shape
=
[
-
1
,
self
.
_num_channels
,
1
,
1
])
excitation
=
paddle
.
unsqueeze
(
excitation
,
axis
=
[
2
,
3
])
out
=
input
*
excitation
return
out
...
...
tools/infer/predict.py
浏览文件 @
1ecf8334
...
...
@@ -90,7 +90,11 @@ def main(args):
predictor
.
run
()
output
=
output_tensor
.
copy_to_cpu
()
return
utils
.
postprocess
(
output
,
args
)
classes
,
scores
=
utils
.
postprocess
(
output
,
args
)
print
(
"Current image file: {}"
.
format
(
args
.
image_file
))
print
(
"
\t
top-1 class: {0}"
.
format
(
classes
[
0
]))
print
(
"
\t
top-1 score: {0}"
.
format
(
scores
[
0
]))
else
:
for
i
in
range
(
0
,
test_num
+
10
):
inputs
=
np
.
random
.
rand
(
args
.
batch_size
,
3
,
224
,
...
...
@@ -115,7 +119,4 @@ def main(args):
if
__name__
==
"__main__"
:
args
=
utils
.
parse_args
()
classes
,
scores
=
main
(
args
)
print
(
"Current image file: {}"
.
format
(
args
.
image_file
))
print
(
"
\t
top-1 class: {0}"
.
format
(
classes
[
0
]))
print
(
"
\t
top-1 score: {0}"
.
format
(
scores
[
0
]))
main
(
args
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录