From 56705e1edd07b31e8a25fdc375a1e76944c62f0d Mon Sep 17 00:00:00 2001 From: shangliang Xu Date: Fri, 5 Nov 2021 16:16:31 +0800 Subject: [PATCH] fix code reference and licence (#4477) --- ppdet/modeling/assigners/atss_assigner.py | 5 ++++- .../assigners/task_aligned_assigner.py | 5 ++++- ppdet/modeling/heads/detr_head.py | 20 ++++++++++++++----- ppdet/modeling/heads/tood_head.py | 7 +++++++ .../transformers/deformable_transformer.py | 3 +++ .../modeling/transformers/detr_transformer.py | 3 +++ ppdet/modeling/transformers/matchers.py | 3 +++ .../transformers/position_encoding.py | 3 +++ ppdet/modeling/transformers/utils.py | 3 +++ 9 files changed, 45 insertions(+), 7 deletions(-) diff --git a/ppdet/modeling/assigners/atss_assigner.py b/ppdet/modeling/assigners/atss_assigner.py index 4835dd1d5..43e6ae2ab 100644 --- a/ppdet/modeling/assigners/atss_assigner.py +++ b/ppdet/modeling/assigners/atss_assigner.py @@ -79,7 +79,10 @@ class ATSSAssigner(nn.Layer): gt_bboxes, bg_index, gt_scores=None): - r"""The assignment is done in following steps + r"""This code is based on + https://github.com/fcjian/TOOD/blob/master/mmdet/core/bbox/assigners/atss_assigner.py + + The assignment is done in following steps 1. compute iou between all bbox (bbox of all pyramid levels) and gt 2. compute center distance between all bbox and gt 3. on each pyramid level, for each gt, select k bbox whose center diff --git a/ppdet/modeling/assigners/task_aligned_assigner.py b/ppdet/modeling/assigners/task_aligned_assigner.py index bae00cc7c..7e31c8afc 100644 --- a/ppdet/modeling/assigners/task_aligned_assigner.py +++ b/ppdet/modeling/assigners/task_aligned_assigner.py @@ -47,7 +47,10 @@ class TaskAlignedAssigner(nn.Layer): gt_bboxes, bg_index, gt_scores=None): - r"""The assignment is done in following steps + r"""This code is based on + https://github.com/fcjian/TOOD/blob/master/mmdet/core/bbox/assigners/task_aligned_assigner.py + + The assignment is done in following steps 1. compute alignment metric between all bbox (bbox of all pyramid levels) and gt 2. select top-k bbox as candidates for each gt 3. limit the positive sample's center in gt (because the anchor-free detector diff --git a/ppdet/modeling/heads/detr_head.py b/ppdet/modeling/heads/detr_head.py index 8f4b4ebbf..6ca3499b9 100644 --- a/ppdet/modeling/heads/detr_head.py +++ b/ppdet/modeling/heads/detr_head.py @@ -28,6 +28,10 @@ __all__ = ['DETRHead', 'DeformableDETRHead'] class MLP(nn.Layer): + """This code is based on + https://github.com/facebookresearch/detr/blob/main/models/detr.py + """ + def __init__(self, input_dim, hidden_dim, output_dim, num_layers): super().__init__() self.num_layers = num_layers @@ -48,7 +52,11 @@ class MLP(nn.Layer): class MultiHeadAttentionMap(nn.Layer): - """This is a 2D attention module, which only returns the attention softmax (no multiplication by value)""" + """This code is based on + https://github.com/facebookresearch/detr/blob/main/models/segmentation.py + + This is a 2D attention module, which only returns the attention softmax (no multiplication by value) + """ def __init__(self, query_dim, hidden_dim, num_heads, dropout=0.0, bias=True): @@ -94,9 +102,11 @@ class MultiHeadAttentionMap(nn.Layer): class MaskHeadFPNConv(nn.Layer): - """ - Simple convolutional head, using group norm. - Upsampling is done using a FPN approach + """This code is based on + https://github.com/facebookresearch/detr/blob/main/models/segmentation.py + + Simple convolutional head, using group norm. + Upsampling is done using a FPN approach """ def __init__(self, input_dim, fpn_dims, context_dim, num_groups=8): @@ -307,7 +317,7 @@ class DeformableDETRHead(nn.Layer): linear_init_(self.score_head) constant_(self.score_head.bias, -4.595) constant_(self.bbox_head.layers[-1].weight) - + with paddle.no_grad(): bias = paddle.zeros_like(self.bbox_head.layers[-1].bias) bias[2:] = -2.0 diff --git a/ppdet/modeling/heads/tood_head.py b/ppdet/modeling/heads/tood_head.py index b244dfdc0..b9dbd17e3 100644 --- a/ppdet/modeling/heads/tood_head.py +++ b/ppdet/modeling/heads/tood_head.py @@ -48,6 +48,10 @@ class ScaleReg(nn.Layer): class TaskDecomposition(nn.Layer): + """This code is based on + https://github.com/fcjian/TOOD/blob/master/mmdet/models/dense_heads/tood_head.py + """ + def __init__( self, feat_channels, @@ -105,6 +109,9 @@ class TaskDecomposition(nn.Layer): @register class TOODHead(nn.Layer): + """This code is based on + https://github.com/fcjian/TOOD/blob/master/mmdet/models/dense_heads/tood_head.py + """ __inject__ = ['nms', 'static_assigner', 'assigner'] __shared__ = ['num_classes'] diff --git a/ppdet/modeling/transformers/deformable_transformer.py b/ppdet/modeling/transformers/deformable_transformer.py index 2ed3ae5f2..0c2089a8b 100644 --- a/ppdet/modeling/transformers/deformable_transformer.py +++ b/ppdet/modeling/transformers/deformable_transformer.py @@ -11,6 +11,9 @@ # 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. +# +# Modified from Deformable-DETR (https://github.com/fundamentalvision/Deformable-DETR) +# Copyright (c) 2020 SenseTime. All Rights Reserved. from __future__ import absolute_import from __future__ import division diff --git a/ppdet/modeling/transformers/detr_transformer.py b/ppdet/modeling/transformers/detr_transformer.py index 65eb12855..bd513772d 100644 --- a/ppdet/modeling/transformers/detr_transformer.py +++ b/ppdet/modeling/transformers/detr_transformer.py @@ -11,6 +11,9 @@ # 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. +# +# Modified from DETR (https://github.com/facebookresearch/detr) +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from __future__ import absolute_import from __future__ import division diff --git a/ppdet/modeling/transformers/matchers.py b/ppdet/modeling/transformers/matchers.py index 6e606ef98..794d86328 100644 --- a/ppdet/modeling/transformers/matchers.py +++ b/ppdet/modeling/transformers/matchers.py @@ -11,6 +11,9 @@ # 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. +# +# Modified from DETR (https://github.com/facebookresearch/detr) +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from __future__ import absolute_import from __future__ import division diff --git a/ppdet/modeling/transformers/position_encoding.py b/ppdet/modeling/transformers/position_encoding.py index 52067ffc8..e54165918 100644 --- a/ppdet/modeling/transformers/position_encoding.py +++ b/ppdet/modeling/transformers/position_encoding.py @@ -11,6 +11,9 @@ # 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. +# +# Modified from DETR (https://github.com/facebookresearch/detr) +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from __future__ import absolute_import from __future__ import division diff --git a/ppdet/modeling/transformers/utils.py b/ppdet/modeling/transformers/utils.py index d4fa3efa3..414ada588 100644 --- a/ppdet/modeling/transformers/utils.py +++ b/ppdet/modeling/transformers/utils.py @@ -11,6 +11,9 @@ # 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. +# +# Modified from DETR (https://github.com/facebookresearch/detr) +# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from __future__ import absolute_import from __future__ import division -- GitLab