yjh0410 1 год назад
Родитель
Сommit
1e451a99a5

+ 4 - 4
odlab/models/detectors/fcos/criterion.py

@@ -6,7 +6,7 @@ from utils.box_ops import get_ious
 from utils.misc import sigmoid_focal_loss
 from utils.distributed_utils import get_world_size, is_dist_avail_and_initialized
 
-from .matcher import FcosMatcher, SimOtaMatcher
+from .matcher import FcosMatcher, AlignedOTAMatcher
 
 
 class SetCriterion(nn.Module):
@@ -33,9 +33,9 @@ class SetCriterion(nn.Module):
         elif cfg.matcher == 'simota':
             self.weight_dict = {'loss_cls': cfg.loss_cls_weight,
                                 'loss_reg': cfg.loss_reg_weight}
-            self.matcher = SimOtaMatcher(cfg.num_classes,
-                                         self.matcher_cfg['soft_center_radius'],
-                                         self.matcher_cfg['topk_candidates'])
+            self.matcher = AlignedOTAMatcher(cfg.num_classes,
+                                             self.matcher_cfg['soft_center_radius'],
+                                             self.matcher_cfg['topk_candidates'])
         else:
             raise NotImplementedError("Unknown matcher: {}.".format(cfg.matcher))
 

+ 4 - 6
odlab/models/detectors/fcos/matcher.py

@@ -1,8 +1,3 @@
-# ---------------------------------------------------------------------
-# Copyright (c) Megvii Inc. All rights reserved.
-# ---------------------------------------------------------------------
-
-
 import math
 import torch
 import torch.nn.functional as F
@@ -226,7 +221,10 @@ class FcosMatcher(object):
         return torch.stack(gt_classes), torch.stack(gt_anchors_deltas), torch.stack(gt_centerness)
 
 
-class SimOtaMatcher(object):
+class AlignedOTAMatcher(object):
+    """
+    This code referenced to https://github.com/open-mmlab/mmyolo/models/task_modules/assigners/batch_dsl_assigner.py
+    """
     def __init__(self, num_classes, soft_center_radius=3.0, topk_candidates=13):
         self.num_classes = num_classes
         self.soft_center_radius = soft_center_radius

+ 3 - 0
odlab/models/detectors/fcos_e2e/matcher.py

@@ -5,6 +5,9 @@ from utils.box_ops import box_iou
 
 
 class AlignedOTAMatcher(object):
+    """
+    This code referenced to https://github.com/open-mmlab/mmyolo/models/task_modules/assigners/batch_dsl_assigner.py
+    """
     def __init__(self,
                  num_classes,
                  soft_center_radius=3.0,

+ 0 - 5
odlab/models/detectors/yolof/criterion.py

@@ -1,8 +1,3 @@
-# ---------------------------------------------------------------------
-# Copyright (c) Megvii Inc. All rights reserved.
-# ---------------------------------------------------------------------
-
-
 import torch
 import torch.nn as nn
 import torch.nn.functional as F

+ 1 - 12
odlab/models/detectors/yolof/matcher.py

@@ -1,8 +1,3 @@
-# ---------------------------------------------------------------------
-# Copyright (c) Megvii Inc. All rights reserved.
-# ---------------------------------------------------------------------
-
-
 import numpy as np
 import torch
 from torch import nn
@@ -11,14 +6,8 @@ from utils.box_ops import *
 
 class UniformMatcher(nn.Module):
     """
-    This code referenced to https://github.com/megvii-model/YOLOF/blob/main/playground/detection/coco/yolof/yolof_base/uniform_matcher.py
-    Uniform Matching between the anchors and gt boxes, which can achieve
-    balance in positive anchors.
-
-    Args:
-        match_times(int): Number of positive anchors for each gt box.
+    This code is referenced to https://github.com/megvii-model/YOLOF/blob/main/playground/detection/coco/yolof/yolof_base/uniform_matcher.py
     """
-
     def __init__(self, match_times: int = 4):
         super().__init__()
         self.match_times = match_times