Browse Source

debug YOLOv8

yjh0410 2 years ago
parent
commit
7d377531a2

+ 0 - 2
config/model_config/yolov8_config.py

@@ -48,7 +48,6 @@ yolov8_cfg = {
         'loss_cls_weight': 0.5,
         'loss_box_weight': 7.5,
         'loss_dfl_weight': 1.5,
-        'loss_box_aux': False,
         # ---------------- Train config ----------------
         'trainer_type': 'yolov8',
     },
@@ -99,7 +98,6 @@ yolov8_cfg = {
         'loss_cls_weight': 0.5,
         'loss_box_weight': 7.5,
         'loss_dfl_weight': 1.5,
-        'loss_box_aux': False,
         # ---------------- Train config ----------------
         'trainer_type': 'yolov8',
     },

+ 2 - 2
models/detectors/yolov1/yolov1.py

@@ -22,7 +22,7 @@ class YOLOv1(nn.Module):
                  deploy=False,
                  nms_class_agnostic :bool = False):
         super(YOLOv1, self).__init__()
-        # ------------------- Basic parameters -------------------
+        # ------------------------- 基础参数 ---------------------------
         self.cfg = cfg                                 # 模型配置文件
         self.img_size = img_size                       # 输入图像大小
         self.device = device                           # cuda或者是cpu
@@ -34,7 +34,7 @@ class YOLOv1(nn.Module):
         self.deploy = deploy
         self.nms_class_agnostic = nms_class_agnostic
         
-        # ------------------- Network Structure -------------------
+        # ----------------------- 模型网络结构 -------------------------
         ## 主干网络
         self.backbone, feat_dim = build_backbone(
             cfg['backbone'], trainable&cfg['pretrained'])

+ 1 - 0
models/detectors/yolov8/build.py

@@ -40,4 +40,5 @@ def build_yolov8(args, cfg, device, num_classes=80, trainable=False, deploy=Fals
     if trainable:
         # build criterion for training
         criterion = build_criterion(cfg, device, num_classes)
+        
     return model, criterion

+ 2 - 2
models/detectors/yolov8/loss.py

@@ -76,8 +76,8 @@ class Criterion(object):
     def __call__(self, outputs, targets, epoch=0):        
         """
             outputs['pred_cls']: List(Tensor) [B, M, C]
-            outputs['pred_regs']: List(Tensor) [B, M, 4*(reg_max+1)]
-            outputs['pred_boxs']: List(Tensor) [B, M, 4]
+            outputs['pred_reg']: List(Tensor) [B, M, 4*(reg_max+1)]
+            outputs['pred_box']: List(Tensor) [B, M, 4]
             outputs['anchors']: List(Tensor) [M, 2]
             outputs['strides']: List(Int) [8, 16, 32] output stride
             outputs['stride_tensor']: List(Tensor) [M, 1]

+ 2 - 2
models/detectors/yolov8/yolov8_pafpn.py

@@ -62,8 +62,8 @@ class Yolov8PaFPN(nn.Module):
                                                   )
         ## P4 -> P5
         self.dowmsample_layer_2 = Conv(round(512*width), round(512*width), k=3, p=1, s=2, act_type=act_type, norm_type=norm_type, depthwise=depthwise)
-        self.bottom_up_layer_2 = Yolov8StageBlock(in_dim = round(512 * width) + c5,
-                                                  out_dim=round(512 * width * ratio),
+        self.bottom_up_layer_2 = Yolov8StageBlock(in_dim       = round(512 * width) + c5,
+                                                  out_dim      = round(512 * width * ratio),
                                                   expand_ratio = 0.5,
                                                   num_blocks   = round(3*depth),
                                                   shortcut     = False,

+ 0 - 2
models/detectors/yolov8/yolov8_pred.py

@@ -19,7 +19,6 @@ class SingleLevelPredLayer(nn.Module):
 
         self.init_bias()
         
-
     def init_bias(self):
         # Init bias
         init_prob = 0.01
@@ -36,7 +35,6 @@ class SingleLevelPredLayer(nn.Module):
         w.data.fill_(0.)
         self.reg_pred.weight = torch.nn.Parameter(w, requires_grad=True)
 
-
     def forward(self, cls_feat, reg_feat):
         """
             in_feats: (Tensor) [B, C, H, W]