67 lines
2.6 KiB
Python
67 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding:utf-8 -*-
|
|
# Copyright (c) Megvii, Inc. and its affiliates.
|
|
|
|
import os
|
|
|
|
from yolox.exp import Exp as MyExp
|
|
|
|
|
|
class Exp(MyExp):
|
|
def __init__(self):
|
|
super(Exp, self).__init__()
|
|
self.data_dir = "/home/kitraining/To_Annotate/"
|
|
self.train_ann = "coco_project_54_train.json"
|
|
self.val_ann = "coco_project_54_valid.json"
|
|
self.test_ann = "coco_project_54_test.json"
|
|
self.num_classes = 3
|
|
self.pretrained_ckpt = r'/home/kitraining/Yolox/YOLOX-main/pretrained/YOLOX_s.pth'
|
|
self.depth = 0.33
|
|
self.width = 0.50
|
|
self.exp_name = os.path.split(os.path.realpath(__file__))[1].split(".")[0]
|
|
|
|
|
|
# -------------- training config --------------------- #
|
|
|
|
self.use_focal_loss = True # Focal Loss for better class imbalance handling
|
|
self.focal_loss_alpha = 0.25
|
|
self.focal_loss_gamma = 1.5
|
|
|
|
self.warmup_epochs = 20 # More warmup
|
|
self.max_epoch = 150 # More epochs for better convergence
|
|
self.act = "silu" # Activation function
|
|
self.no_aug_epochs = 30 # No augmentation for last epochs to stabilize training
|
|
|
|
self.class_weights = [1.0, 1.0, 1.0] # Weights for each class to handle imbalance
|
|
|
|
# Thresholds
|
|
self.test_conf = 0.15 # Low to catch more the second class
|
|
self.nmsthre = 0.5 # IoU threshold for NMS
|
|
|
|
# Data Augmentation intens to improve generalization
|
|
self.enable_mixup = True
|
|
self.mixup_prob = 0.7 # mixup
|
|
self.mosaic_prob = 0.8 # mosaico
|
|
self.degrees = 20.0 # Rotation
|
|
self.translate = 0.2 # Translation
|
|
self.scale = (0.5, 1.5) # Scaling
|
|
self.shear = 5.0 # Shear
|
|
self.flip_prob = 0.8
|
|
self.hsv_prob = 1.0
|
|
|
|
# Learning rate
|
|
self.basic_lr_per_img = 0.001 / 64.0 # Lower LR to avoid divergence
|
|
self.scheduler = "yoloxwarmcos"
|
|
self.min_lr_ratio = 0.01
|
|
|
|
# Loss weights
|
|
self.cls_loss_weight = 8.0 # More weight to the classification loss
|
|
self.obj_loss_weight = 1.0
|
|
self.reg_loss_weight = 1.0
|
|
|
|
# Input size bigger for better detection of small objects like babys
|
|
self.input_size = (832, 832)
|
|
self.test_size = (832, 832)
|
|
|
|
# Batch size
|
|
self.batch_size = 5 # Reduce if you have memory issues |