Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
93c173ce
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
93c173ce
编写于
5月 31, 2022
作者:
K
Kaipeng Deng
提交者:
GitHub
5月 31, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix class init when import ppdet files (#5998)
* fix class init when import ppdet files
上级
271347a3
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
58 addition
and
10 deletion
+58
-10
ppdet/modeling/cls_utils.py
ppdet/modeling/cls_utils.py
+40
-0
ppdet/modeling/heads/bbox_head.py
ppdet/modeling/heads/bbox_head.py
+2
-1
ppdet/modeling/heads/cascade_head.py
ppdet/modeling/heads/cascade_head.py
+2
-1
ppdet/modeling/heads/face_head.py
ppdet/modeling/heads/face_head.py
+2
-1
ppdet/modeling/heads/mask_head.py
ppdet/modeling/heads/mask_head.py
+2
-1
ppdet/modeling/heads/s2anet_head.py
ppdet/modeling/heads/s2anet_head.py
+2
-1
ppdet/modeling/heads/ssd_head.py
ppdet/modeling/heads/ssd_head.py
+2
-1
ppdet/modeling/proposal_generator/rpn_head.py
ppdet/modeling/proposal_generator/rpn_head.py
+6
-4
未找到文件。
ppdet/modeling/cls_utils.py
0 → 100644
浏览文件 @
93c173ce
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# 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.
def
_get_class_default_kwargs
(
cls
,
*
args
,
**
kwargs
):
"""
Get default arguments of a class in dict format, if args and
kwargs is specified, it will replace default arguments
"""
varnames
=
cls
.
__init__
.
__code__
.
co_varnames
argcount
=
cls
.
__init__
.
__code__
.
co_argcount
keys
=
varnames
[:
argcount
]
assert
keys
[
0
]
==
'self'
keys
=
keys
[
1
:]
values
=
list
(
cls
.
__init__
.
__defaults__
)
assert
len
(
values
)
==
len
(
keys
)
if
len
(
args
)
>
0
:
for
i
,
arg
in
enumerate
(
args
):
values
[
i
]
=
arg
default_kwargs
=
dict
(
zip
(
keys
,
values
))
if
len
(
kwargs
)
>
0
:
for
k
,
v
in
kwargs
.
items
():
default_kwargs
[
k
]
=
v
return
default_kwargs
ppdet/modeling/heads/bbox_head.py
浏览文件 @
93c173ce
...
...
@@ -24,6 +24,7 @@ from ppdet.core.workspace import register, create
from
.roi_extractor
import
RoIAlign
from
..shape_spec
import
ShapeSpec
from
..bbox_utils
import
bbox2delta
from
..cls_utils
import
_get_class_default_kwargs
from
ppdet.modeling.layers
import
ConvNormLayer
__all__
=
[
'TwoFCHead'
,
'XConvNormHead'
,
'BBoxHead'
]
...
...
@@ -178,7 +179,7 @@ class BBoxHead(nn.Layer):
def
__init__
(
self
,
head
,
in_channel
,
roi_extractor
=
RoIAlign
().
__dict__
,
roi_extractor
=
_get_class_default_kwargs
(
RoIAlign
)
,
bbox_assigner
=
'BboxAssigner'
,
with_pool
=
False
,
num_classes
=
80
,
...
...
ppdet/modeling/heads/cascade_head.py
浏览文件 @
93c173ce
...
...
@@ -22,6 +22,7 @@ from .bbox_head import BBoxHead, TwoFCHead, XConvNormHead
from
.roi_extractor
import
RoIAlign
from
..shape_spec
import
ShapeSpec
from
..bbox_utils
import
delta2bbox
,
clip_bbox
,
nonempty_bbox
from
..cls_utils
import
_get_class_default_kwargs
__all__
=
[
'CascadeTwoFCHead'
,
'CascadeXConvNormHead'
,
'CascadeHead'
]
...
...
@@ -153,7 +154,7 @@ class CascadeHead(BBoxHead):
def
__init__
(
self
,
head
,
in_channel
,
roi_extractor
=
RoIAlign
().
__dict__
,
roi_extractor
=
_get_class_default_kwargs
(
RoIAlign
)
,
bbox_assigner
=
'BboxAssigner'
,
num_classes
=
80
,
bbox_weight
=
[[
10.
,
10.
,
5.
,
5.
],
[
20.0
,
20.0
,
10.0
,
10.0
],
...
...
ppdet/modeling/heads/face_head.py
浏览文件 @
93c173ce
...
...
@@ -17,6 +17,7 @@ import paddle.nn as nn
from
ppdet.core.workspace
import
register
from
..layers
import
AnchorGeneratorSSD
from
..cls_utils
import
_get_class_default_kwargs
@
register
...
...
@@ -39,7 +40,7 @@ class FaceHead(nn.Layer):
def
__init__
(
self
,
num_classes
=
80
,
in_channels
=
[
96
,
96
],
anchor_generator
=
AnchorGeneratorSSD
().
__dict__
,
anchor_generator
=
_get_class_default_kwargs
(
AnchorGeneratorSSD
)
,
kernel_size
=
3
,
padding
=
1
,
conv_decay
=
0.
,
...
...
ppdet/modeling/heads/mask_head.py
浏览文件 @
93c173ce
...
...
@@ -20,6 +20,7 @@ from paddle.nn.initializer import KaimingNormal
from
ppdet.core.workspace
import
register
,
create
from
ppdet.modeling.layers
import
ConvNormLayer
from
.roi_extractor
import
RoIAlign
from
..cls_utils
import
_get_class_default_kwargs
@
register
...
...
@@ -120,7 +121,7 @@ class MaskHead(nn.Layer):
def
__init__
(
self
,
head
,
roi_extractor
=
RoIAlign
().
__dict__
,
roi_extractor
=
_get_class_default_kwargs
(
RoIAlign
)
,
mask_assigner
=
'MaskAssigner'
,
num_classes
=
80
,
share_bbox_feat
=
False
,
...
...
ppdet/modeling/heads/s2anet_head.py
浏览文件 @
93c173ce
...
...
@@ -23,6 +23,7 @@ from ppdet.core.workspace import register
from
ppdet.modeling
import
ops
from
ppdet.modeling
import
bbox_utils
from
ppdet.modeling.proposal_generator.target_layer
import
RBoxAssigner
from
..cls_utils
import
_get_class_default_kwargs
import
numpy
as
np
...
...
@@ -230,7 +231,7 @@ class S2ANetHead(nn.Layer):
align_conv_type
=
'AlignConv'
,
align_conv_size
=
3
,
use_sigmoid_cls
=
True
,
anchor_assign
=
RBoxAssigner
().
__dict__
,
anchor_assign
=
_get_class_default_kwargs
(
RBoxAssigner
)
,
reg_loss_weight
=
[
1.0
,
1.0
,
1.0
,
1.0
,
1.1
],
cls_loss_weight
=
[
1.1
,
1.05
],
reg_loss_type
=
'l1'
):
...
...
ppdet/modeling/heads/ssd_head.py
浏览文件 @
93c173ce
...
...
@@ -20,6 +20,7 @@ from paddle.regularizer import L2Decay
from
paddle
import
ParamAttr
from
..layers
import
AnchorGeneratorSSD
from
..cls_utils
import
_get_class_default_kwargs
class
SepConvLayer
(
nn
.
Layer
):
...
...
@@ -113,7 +114,7 @@ class SSDHead(nn.Layer):
def
__init__
(
self
,
num_classes
=
80
,
in_channels
=
(
512
,
1024
,
512
,
256
,
256
,
256
),
anchor_generator
=
AnchorGeneratorSSD
().
__dict__
,
anchor_generator
=
_get_class_default_kwargs
(
AnchorGeneratorSSD
)
,
kernel_size
=
3
,
padding
=
1
,
use_sepconv
=
False
,
...
...
ppdet/modeling/proposal_generator/rpn_head.py
浏览文件 @
93c173ce
...
...
@@ -21,6 +21,7 @@ from ppdet.core.workspace import register
from
.anchor_generator
import
AnchorGenerator
from
.target_layer
import
RPNTargetAssign
from
.proposal_generator
import
ProposalGenerator
from
..cls_utils
import
_get_class_default_kwargs
class
RPNFeat
(
nn
.
Layer
):
...
...
@@ -69,10 +70,11 @@ class RPNHead(nn.Layer):
__shared__
=
[
'export_onnx'
]
def
__init__
(
self
,
anchor_generator
=
AnchorGenerator
().
__dict__
,
rpn_target_assign
=
RPNTargetAssign
().
__dict__
,
train_proposal
=
ProposalGenerator
(
12000
,
2000
).
__dict__
,
test_proposal
=
ProposalGenerator
().
__dict__
,
anchor_generator
=
_get_class_default_kwargs
(
AnchorGenerator
),
rpn_target_assign
=
_get_class_default_kwargs
(
RPNTargetAssign
),
train_proposal
=
_get_class_default_kwargs
(
ProposalGenerator
,
12000
,
2000
),
test_proposal
=
_get_class_default_kwargs
(
ProposalGenerator
),
in_channel
=
1024
,
export_onnx
=
False
):
super
(
RPNHead
,
self
).
__init__
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录