Procházet zdrojové kódy

use YOLOX-style MixUp

yjh0410 před 2 roky
rodič
revize
6bcf6e4947
3 změnil soubory, kde provedl 150 přidání a 15 odebrání
  1. 20 0
      config/__init__.py
  2. 115 0
      config/transform_config.py
  3. 15 15
      config/yolox_config.py

+ 20 - 0
config/__init__.py

@@ -44,6 +44,12 @@ from .transform_config import (
     yolov5_medium_trans_config,
     yolov5_large_trans_config,
     yolov5_huge_trans_config,
+    yolox_nano_trans_config,
+    yolox_tiny_trans_config,
+    yolox_small_trans_config,
+    yolox_medium_trans_config,
+    yolox_large_trans_config,
+    yolox_huge_trans_config,
     ssd_trans_config
 )
 
@@ -68,4 +74,18 @@ def build_trans_config(trans_config='ssd'):
     elif trans_config == 'yolov5_huge':
         cfg = yolov5_huge_trans_config
         
+    # YOLOX-style transform 
+    elif trans_config == 'yolox_nano':
+        cfg = yolox_nano_trans_config
+    elif trans_config == 'yolox_tiny':
+        cfg = yolox_tiny_trans_config
+    elif trans_config == 'yolox_small':
+        cfg = yolox_small_trans_config
+    elif trans_config == 'yolox_medium':
+        cfg = yolox_medium_trans_config
+    elif trans_config == 'yolox_large':
+        cfg = yolox_large_trans_config
+    elif trans_config == 'yolox_huge':
+        cfg = yolox_huge_trans_config
+        
     return cfg

+ 115 - 0
config/transform_config.py

@@ -115,6 +115,121 @@ yolov5_nano_trans_config = {
     'mixup_scale': [0.5, 1.5]   # "mixup_scale" is not used for YOLOv5MixUp
 }
 
+# ----------------------- YOLOv5-Style -----------------------
+yolox_huge_trans_config = {
+    'aug_type': 'yolov5',
+    # Basic Augment
+    'degrees': 0.0,
+    'translate': 0.2,
+    'scale': 0.9,
+    'shear': 0.0,
+    'perspective': 0.0,
+    'hsv_h': 0.015,
+    'hsv_s': 0.7,
+    'hsv_v': 0.4,
+    # Mosaic & Mixup
+    'mosaic_prob': 1.0,
+    'mixup_prob': 1.0,
+    'mosaic_type': 'yolov5_mosaic',
+    'mixup_type': 'yolox_mixup',
+    'mixup_scale': [0.5, 1.5]   # "mixup_scale" is not used for YOLOv5MixUp
+}
+
+yolox_large_trans_config = {
+    'aug_type': 'yolov5',
+    # Basic Augment
+    'degrees': 0.0,
+    'translate': 0.2,
+    'scale': 0.9,
+    'shear': 0.0,
+    'perspective': 0.0,
+    'hsv_h': 0.015,
+    'hsv_s': 0.7,
+    'hsv_v': 0.4,
+    # Mosaic & Mixup
+    'mosaic_prob': 1.0,
+    'mixup_prob': 1.0,
+    'mosaic_type': 'yolov5_mosaic',
+    'mixup_type': 'yolox_mixup',
+    'mixup_scale': [0.5, 1.5]   # "mixup_scale" is not used for YOLOv5MixUp
+}
+
+yolox_medium_trans_config = {
+    'aug_type': 'yolov5',
+    # Basic Augment
+    'degrees': 0.0,
+    'translate': 0.2,
+    'scale': 0.9,
+    'shear': 0.0,
+    'perspective': 0.0,
+    'hsv_h': 0.015,
+    'hsv_s': 0.7,
+    'hsv_v': 0.4,
+    # Mosaic & Mixup
+    'mosaic_prob': 1.0,
+    'mixup_prob': 1.0,
+    'mosaic_type': 'yolov5_mosaic',
+    'mixup_type': 'yolox_mixup',
+    'mixup_scale': [0.5, 1.5]   # "mixup_scale" is not used for YOLOv5MixUp
+}
+
+yolox_small_trans_config = {
+    'aug_type': 'yolov5',
+    # Basic Augment
+    'degrees': 0.0,
+    'translate': 0.2,
+    'scale': 0.9,
+    'shear': 0.0,
+    'perspective': 0.0,
+    'hsv_h': 0.015,
+    'hsv_s': 0.7,
+    'hsv_v': 0.4,
+    # Mosaic & Mixup
+    'mosaic_prob': 1.0,
+    'mixup_prob': 1.0,
+    'mosaic_type': 'yolov5_mosaic',
+    'mixup_type': 'yolox_mixup',
+    'mixup_scale': [0.5, 1.5]   # "mixup_scale" is not used for YOLOv5MixUp
+}
+
+yolox_tiny_trans_config = {
+    'aug_type': 'yolov5',
+    # Basic Augment
+    'degrees': 0.0,
+    'translate': 0.1,
+    'scale': 0.5,
+    'shear': 0.0,
+    'perspective': 0.0,
+    'hsv_h': 0.015,
+    'hsv_s': 0.7,
+    'hsv_v': 0.4,
+    # Mosaic & Mixup
+    'mosaic_prob': 1.0,
+    'mixup_prob': 0.5,
+    'mosaic_type': 'yolov5_mosaic',
+    'mixup_type': 'yolox_mixup',
+    'mixup_scale': [0.5, 1.5]   # "mixup_scale" is not used for YOLOv5MixUp
+}
+
+yolox_nano_trans_config = {
+    'aug_type': 'yolov5',
+    # Basic Augment
+    'degrees': 0.0,
+    'translate': 0.1,
+    'scale': 0.5,
+    'shear': 0.0,
+    'perspective': 0.0,
+    'hsv_h': 0.015,
+    'hsv_s': 0.7,
+    'hsv_v': 0.4,
+    # Mosaic & Mixup
+    'mosaic_prob': 0.5,
+    'mixup_prob': 0.0,
+    'mosaic_type': 'yolov5_mosaic',
+    'mixup_type': 'yolox_mixup',
+    'mixup_scale': [0.5, 1.5]   # "mixup_scale" is not used for YOLOv5MixUp
+}
+
 # ----------------------- SSD-Style -----------------------
 ssd_trans_config = {
     'aug_type': 'ssd',

+ 15 - 15
config/yolox_config.py

@@ -31,7 +31,7 @@ yolox_cfg = {
         # ---------------- Train config ----------------
         ## input
         'multi_scale': [0.5, 1.5],   # 320 -> 960
-        'trans_type': 'yolov5_tiny',
+        'trans_type': 'yolox_tiny',
         # ---------------- Assignment config ----------------
         ## matcher
         'matcher': {'center_sampling_radius': 2.5,
@@ -43,10 +43,10 @@ yolox_cfg = {
         'loss_box_weight': 5.0,
         # ---------------- Train config ----------------
         ## close strong augmentation
-        'no_aug_epoch': 10,
+        'no_aug_epoch': 20,
         ## optimizer
         'optimizer': 'sgd',        # optional: sgd, AdamW
-        'momentum': 0.937,         # SGD: 0.937;    AdamW: None
+        'momentum': 0.9,           # SGD: 0.9;    AdamW: None
         'weight_decay': 5e-4,      # SGD: 5e-4;     AdamW: 5e-2
         'clip_grad': 10,           # SGD: 10.0;     AdamW: -1
         ## model EMA
@@ -89,7 +89,7 @@ yolox_cfg = {
         # ---------------- Train config ----------------
         ## input
         'multi_scale': [0.5, 1.5],   # 320 -> 960
-        'trans_type': 'yolov5_small',
+        'trans_type': 'yolox_small',
         # ---------------- Assignment config ----------------
         ## matcher
         'matcher': {'center_sampling_radius': 2.5,
@@ -101,10 +101,10 @@ yolox_cfg = {
         'loss_box_weight': 5.0,
         # ---------------- Train config ----------------
         ## close strong augmentation
-        'no_aug_epoch': 10,
+        'no_aug_epoch': 20,
         ## optimizer
         'optimizer': 'sgd',        # optional: sgd, AdamW
-        'momentum': 0.937,         # SGD: 0.937;    AdamW: None
+        'momentum': 0.9,           # SGD: 0.9;    AdamW: None
         'weight_decay': 5e-4,      # SGD: 5e-4;     AdamW: 5e-2
         'clip_grad': 10,           # SGD: 10.0;     AdamW: -1
         ## model EMA
@@ -147,7 +147,7 @@ yolox_cfg = {
         # ---------------- Train config ----------------
         ## input
         'multi_scale': [0.5, 1.5],   # 320 -> 960
-        'trans_type': 'yolov5_medium',
+        'trans_type': 'yolox_medium',
         # ---------------- Assignment config ----------------
         ## matcher
         'matcher': {'center_sampling_radius': 2.5,
@@ -159,10 +159,10 @@ yolox_cfg = {
         'loss_box_weight': 5.0,
         # ---------------- Train config ----------------
         ## close strong augmentation
-        'no_aug_epoch': 10,
+        'no_aug_epoch': 20,
         ## optimizer
         'optimizer': 'sgd',        # optional: sgd, AdamW
-        'momentum': 0.937,         # SGD: 0.937;    AdamW: None
+        'momentum': 0.9,           # SGD: 0.9;    AdamW: None
         'weight_decay': 5e-4,      # SGD: 5e-4;     AdamW: 5e-2
         'clip_grad': 10,           # SGD: 10.0;     AdamW: -1
         ## model EMA
@@ -205,7 +205,7 @@ yolox_cfg = {
         # ---------------- Train config ----------------
         ## input
         'multi_scale': [0.5, 1.25],   # 320 -> 800
-        'trans_type': 'yolov5_large',
+        'trans_type': 'yolox_large',
         # ---------------- Assignment config ----------------
         ## matcher
         'matcher': {'center_sampling_radius': 2.5,
@@ -217,10 +217,10 @@ yolox_cfg = {
         'loss_box_weight': 5.0,
         # ---------------- Train config ----------------
         ## close strong augmentation
-        'no_aug_epoch': 10,
+        'no_aug_epoch': 20,
         ## optimizer
         'optimizer': 'sgd',        # optional: sgd, AdamW
-        'momentum': 0.937,         # SGD: 0.937;    AdamW: None
+        'momentum': 0.9,           # SGD: 0.9;    AdamW: None
         'weight_decay': 5e-4,      # SGD: 5e-4;     AdamW: 5e-2
         'clip_grad': 10,           # SGD: 10.0;     AdamW: -1
         ## model EMA
@@ -263,7 +263,7 @@ yolox_cfg = {
         # ---------------- Train config ----------------
         ## input
         'multi_scale': [0.5, 1.25],   # 320 -> 800
-        'trans_type': 'yolov5_huge',
+        'trans_type': 'yolox_huge',
         # ---------------- Assignment config ----------------
         ## matcher
         'matcher': {'center_sampling_radius': 2.5,
@@ -275,10 +275,10 @@ yolox_cfg = {
         'loss_box_weight': 5.0,
         # ---------------- Train config ----------------
         ## close strong augmentation
-        'no_aug_epoch': 10,
+        'no_aug_epoch': 20,
         ## optimizer
         'optimizer': 'sgd',        # optional: sgd, AdamW
-        'momentum': 0.937,         # SGD: 0.937;    AdamW: None
+        'momentum': 0.9,           # SGD: 0.9;    AdamW: None
         'weight_decay': 5e-4,      # SGD: 5e-4;     AdamW: 5e-2
         'clip_grad': 10,           # SGD: 10.0;     AdamW: -1
         ## model EMA