yjh0410 il y a 1 an
Parent
commit
60435e8155
3 fichiers modifiés avec 0 ajouts et 44 suppressions
  1. 0 2
      models/yolov3/matcher.py
  2. 0 2
      models/yolov4/matcher.py
  3. 0 40
      models/yolov8/yolov8_backbone.py

+ 0 - 2
models/yolov3/matcher.py

@@ -12,7 +12,6 @@ class Yolov3Matcher(object):
             for anchor in anchor_size]
             )  # [KA, 4]
 
-
     def compute_iou(self, anchor_boxes, gt_box):
         """
             anchor_boxes : ndarray -> [KA, 4] (cx, cy, bw, bh).
@@ -50,7 +49,6 @@ class Yolov3Matcher(object):
         
         return iou
 
-
     @torch.no_grad()
     def __call__(self, fmp_sizes, fpn_strides, targets):
         """

+ 0 - 2
models/yolov4/matcher.py

@@ -12,7 +12,6 @@ class Yolov4Matcher(object):
             for anchor in anchor_size]
             )  # [KA, 4]
 
-
     def compute_iou(self, anchor_boxes, gt_box):
         """
             anchor_boxes : ndarray -> [KA, 4] (cx, cy, bw, bh).
@@ -50,7 +49,6 @@ class Yolov4Matcher(object):
         
         return iou
 
-
     @torch.no_grad()
     def __call__(self, fmp_sizes, fpn_strides, targets):
         """

+ 0 - 40
models/yolov8/yolov8_backbone.py

@@ -7,16 +7,6 @@ except:
     from  yolov8_basic import BasicConv, ELANLayer
 
 
-# IN1K pretrained weight
-pretrained_urls = {
-    'n': "https://github.com/yjh0410/ICLab/releases/download/in1k_pretrained/rtcnet_n_in1k_62.1.pth",
-    's': "https://github.com/yjh0410/ICLab/releases/download/in1k_pretrained/rtcnet_s_in1k_71.3.pth",
-    'm': None,
-    'l': None,
-    'x': None,
-}
-
-
 # ---------------------------- Basic functions ----------------------------
 class Yolov8Backbone(nn.Module):
     def __init__(self, cfg):
@@ -94,10 +84,6 @@ class Yolov8Backbone(nn.Module):
         # Initialize all layers
         self.init_weights()
         
-        # Load imagenet pretrained weight
-        if cfg.use_pretrained:
-            self.load_pretrained()
-
     def init_weights(self):
         """Initialize the parameters."""
         for m in self.modules():
@@ -106,31 +92,6 @@ class Yolov8Backbone(nn.Module):
                 # reset the Conv2d initialization parameters
                 m.reset_parameters()
 
-    def load_pretrained(self):
-        url = pretrained_urls[self.model_scale]
-        if url is not None:
-            print('Loading backbone pretrained weight from : {}'.format(url))
-            # checkpoint state dict
-            checkpoint = torch.hub.load_state_dict_from_url(
-                url=url, map_location="cpu", check_hash=True)
-            checkpoint_state_dict = checkpoint.pop("model")
-            # model state dict
-            model_state_dict = self.state_dict()
-            # check
-            for k in list(checkpoint_state_dict.keys()):
-                if k in model_state_dict:
-                    shape_model = tuple(model_state_dict[k].shape)
-                    shape_checkpoint = tuple(checkpoint_state_dict[k].shape)
-                    if shape_model != shape_checkpoint:
-                        checkpoint_state_dict.pop(k)
-                else:
-                    checkpoint_state_dict.pop(k)
-                    print('Unused key: ', k)
-            # load the weight
-            self.load_state_dict(checkpoint_state_dict)
-        else:
-            print('No pretrained weight for model scale: {}.'.format(self.model_scale))
-
     def forward(self, x):
         c1 = self.layer_1(x)
         c2 = self.layer_2(c1)
@@ -163,7 +124,6 @@ if __name__ == '__main__':
             self.depth = 1.0
             self.ratio = 1.0
             self.scale = "n"
-            self.use_pretrained = True
 
     cfg = BaseConfig()
     model = build_backbone(cfg)