|
| 1 | +from yacs.config import CfgNode as CN |
| 2 | + |
| 3 | +# ----------------------------------------------------------------------------- |
| 4 | +# Convention about Training / Test specific parameters |
| 5 | +# ----------------------------------------------------------------------------- |
| 6 | +# Whenever an argument can be either used for training or for testing, the |
| 7 | +# corresponding name will be post-fixed by a _TRAIN for a training parameter, |
| 8 | + |
| 9 | +# ----------------------------------------------------------------------------- |
| 10 | +# Config definition |
| 11 | +# ----------------------------------------------------------------------------- |
| 12 | + |
| 13 | +_C = CN() |
| 14 | +# ----------------------------------------------------------------------------- |
| 15 | +# MODEL |
| 16 | +# ----------------------------------------------------------------------------- |
| 17 | +_C.MODEL = CN() |
| 18 | +# Using cuda or cpu for training |
| 19 | +_C.MODEL.DEVICE = "cuda" |
| 20 | +# ID number of GPU |
| 21 | +_C.MODEL.DEVICE_ID = '0' |
| 22 | +# Name of backbone |
| 23 | +_C.MODEL.NAME = 'resnet50' |
| 24 | +# Last stride of backbone |
| 25 | +_C.MODEL.LAST_STRIDE = 1 |
| 26 | +# Path to pretrained model of backbone |
| 27 | +_C.MODEL.PRETRAIN_PATH = '' |
| 28 | +_C.MODEL.PRETRAIN_HW_RATIO = 1 |
| 29 | + |
| 30 | +# Use ImageNet pretrained model to initialize backbone or use self trained model to initialize the whole model |
| 31 | +# Options: 'imagenet' , 'self' , 'finetune' |
| 32 | +_C.MODEL.PRETRAIN_CHOICE = 'imagenet' |
| 33 | + |
| 34 | +# If train with BNNeck, options: 'bnneck' or 'no' |
| 35 | +_C.MODEL.NECK = 'bnneck' |
| 36 | +# If train loss include center loss, options: 'yes' or 'no'. Loss with center loss has different optimizer configuration |
| 37 | +_C.MODEL.IF_WITH_CENTER = 'no' |
| 38 | + |
| 39 | +_C.MODEL.ID_LOSS_TYPE = 'softmax' |
| 40 | +_C.MODEL.ID_LOSS_WEIGHT = 1.0 |
| 41 | +_C.MODEL.TRIPLET_LOSS_WEIGHT = 1.0 |
| 42 | + |
| 43 | +_C.MODEL.METRIC_LOSS_TYPE = 'triplet' |
| 44 | +# If train with multi-gpu ddp mode, options: 'True', 'False' |
| 45 | +_C.MODEL.DIST_TRAIN = False |
| 46 | +# If train with soft triplet loss, options: 'True', 'False' |
| 47 | +_C.MODEL.NO_MARGIN = False |
| 48 | +# If train with label smooth, options: 'on', 'off' |
| 49 | +_C.MODEL.IF_LABELSMOOTH = 'on' |
| 50 | +# If train with arcface loss, options: 'True', 'False' |
| 51 | +_C.MODEL.COS_LAYER = False |
| 52 | + |
| 53 | +_C.MODEL.DROPOUT_RATE = 0.0 |
| 54 | +# Reduce feature dim |
| 55 | +_C.MODEL.REDUCE_FEAT_DIM = False |
| 56 | +_C.MODEL.FEAT_DIM = 512 |
| 57 | +# Transformer setting |
| 58 | +_C.MODEL.DROP_PATH = 0.1 |
| 59 | +_C.MODEL.DROP_OUT = 0.0 |
| 60 | +_C.MODEL.ATT_DROP_RATE = 0.0 |
| 61 | +_C.MODEL.TRANSFORMER_TYPE = 'None' |
| 62 | +_C.MODEL.STRIDE_SIZE = [16, 16] |
| 63 | +_C.MODEL.GEM_POOLING = False |
| 64 | +_C.MODEL.STEM_CONV = False |
| 65 | + |
| 66 | +# JPM Parameter |
| 67 | +_C.MODEL.JPM = False |
| 68 | +_C.MODEL.SHIFT_NUM = 5 |
| 69 | +_C.MODEL.SHUFFLE_GROUP = 2 |
| 70 | +_C.MODEL.DEVIDE_LENGTH = 4 |
| 71 | +_C.MODEL.RE_ARRANGE = True |
| 72 | + |
| 73 | +# SIE Parameter |
| 74 | +_C.MODEL.SIE_COE = 3.0 |
| 75 | +_C.MODEL.SIE_CAMERA = False |
| 76 | +_C.MODEL.SIE_VIEW = False |
| 77 | + |
| 78 | +# Semantic Weight |
| 79 | +_C.MODEL.SEMANTIC_WEIGHT = 1.0 |
| 80 | + |
| 81 | +# ----------------------------------------------------------------------------- |
| 82 | +# INPUT |
| 83 | +# ----------------------------------------------------------------------------- |
| 84 | +_C.INPUT = CN() |
| 85 | +# Size of the image during training |
| 86 | +_C.INPUT.SIZE_TRAIN = [384, 128] |
| 87 | +# Size of the image during test |
| 88 | +_C.INPUT.SIZE_TEST = [384, 128] |
| 89 | +# Random probability for image horizontal flip |
| 90 | +_C.INPUT.PROB = 0.5 |
| 91 | +# Random probability for random erasing |
| 92 | +_C.INPUT.RE_PROB = 0.5 |
| 93 | +# Values to be used for image normalization |
| 94 | +_C.INPUT.PIXEL_MEAN = [0.485, 0.456, 0.406] |
| 95 | +# Values to be used for image normalization |
| 96 | +_C.INPUT.PIXEL_STD = [0.229, 0.224, 0.225] |
| 97 | +# Value of padding size |
| 98 | +_C.INPUT.PADDING = 10 |
| 99 | + |
| 100 | +# ----------------------------------------------------------------------------- |
| 101 | +# Dataset |
| 102 | +# ----------------------------------------------------------------------------- |
| 103 | +_C.DATASETS = CN() |
| 104 | +# List of the dataset names for training, as present in paths_catalog.py |
| 105 | +_C.DATASETS.NAMES = ('market1501') |
| 106 | +# Root directory where datasets should be used (and downloaded if not found) |
| 107 | +_C.DATASETS.ROOT_DIR = ('../data') |
| 108 | +_C.DATASETS.ROOT_TRAIN_DIR = ('../data') |
| 109 | +_C.DATASETS.ROOT_VAL_DIR = ('../data') |
| 110 | + |
| 111 | + |
| 112 | +# ----------------------------------------------------------------------------- |
| 113 | +# DataLoader |
| 114 | +# ----------------------------------------------------------------------------- |
| 115 | +_C.DATALOADER = CN() |
| 116 | +# Number of data loading threads |
| 117 | +_C.DATALOADER.NUM_WORKERS = 8 |
| 118 | +# Sampler for data loading |
| 119 | +_C.DATALOADER.SAMPLER = 'softmax' |
| 120 | +# Number of instance for one batch |
| 121 | +_C.DATALOADER.NUM_INSTANCE = 16 |
| 122 | +# remove tail data |
| 123 | +_C.DATALOADER.REMOVE_TAIL = 0 |
| 124 | + |
| 125 | +# ---------------------------------------------------------------------------- # |
| 126 | +# Solver |
| 127 | +# ---------------------------------------------------------------------------- # |
| 128 | +_C.SOLVER = CN() |
| 129 | +# Name of optimizer |
| 130 | +_C.SOLVER.OPTIMIZER_NAME = "Adam" |
| 131 | +# Number of max epoches |
| 132 | +_C.SOLVER.MAX_EPOCHS = 100 |
| 133 | +# Base learning rate |
| 134 | +_C.SOLVER.BASE_LR = 3e-4 |
| 135 | +# Whether using larger learning rate for fc layer |
| 136 | +_C.SOLVER.LARGE_FC_LR = False |
| 137 | +# Factor of learning bias |
| 138 | +_C.SOLVER.BIAS_LR_FACTOR = 1 |
| 139 | +# Factor of learning bias |
| 140 | +_C.SOLVER.SEED = 1234 |
| 141 | +# Momentum |
| 142 | +_C.SOLVER.MOMENTUM = 0.9 |
| 143 | +# Margin of triplet loss |
| 144 | +_C.SOLVER.MARGIN = 0.3 |
| 145 | +# Learning rate of SGD to learn the centers of center loss |
| 146 | +_C.SOLVER.CENTER_LR = 0.5 |
| 147 | +# Balanced weight of center loss |
| 148 | +_C.SOLVER.CENTER_LOSS_WEIGHT = 0.0005 |
| 149 | + |
| 150 | +# Settings of weight decay |
| 151 | +_C.SOLVER.WEIGHT_DECAY = 0.0005 |
| 152 | +_C.SOLVER.WEIGHT_DECAY_BIAS = 0.0005 |
| 153 | + |
| 154 | +# decay rate of learning rate |
| 155 | +_C.SOLVER.GAMMA = 0.1 |
| 156 | +# decay step of learning rate |
| 157 | +_C.SOLVER.STEPS = (40, 70) |
| 158 | +# warm up factor |
| 159 | +_C.SOLVER.WARMUP_FACTOR = 0.01 |
| 160 | +# warm up epochs |
| 161 | +_C.SOLVER.WARMUP_EPOCHS = 5 |
| 162 | +# method of warm up, option: 'constant','linear' |
| 163 | +_C.SOLVER.WARMUP_METHOD = "cosine" |
| 164 | + |
| 165 | +_C.SOLVER.COSINE_MARGIN = 0.5 |
| 166 | +_C.SOLVER.COSINE_SCALE = 30 |
| 167 | + |
| 168 | +# epoch number of saving checkpoints |
| 169 | +_C.SOLVER.CHECKPOINT_PERIOD = 10 |
| 170 | +# iteration of display training log |
| 171 | +_C.SOLVER.LOG_PERIOD = 100 |
| 172 | +# epoch number of validation |
| 173 | +_C.SOLVER.EVAL_PERIOD = 10 |
| 174 | +# Number of images per batch |
| 175 | +# This is global, so if we have 8 GPUs and IMS_PER_BATCH = 128, each GPU will |
| 176 | +# contain 16 images per batch |
| 177 | +_C.SOLVER.IMS_PER_BATCH = 64 |
| 178 | +_C.SOLVER.TRP_L2 = False |
| 179 | + |
| 180 | +# ---------------------------------------------------------------------------- # |
| 181 | +# TEST |
| 182 | +# ---------------------------------------------------------------------------- # |
| 183 | + |
| 184 | +_C.TEST = CN() |
| 185 | +# Number of images per batch during test |
| 186 | +_C.TEST.IMS_PER_BATCH = 128 |
| 187 | +# If test with re-ranking, options: 'True','False' |
| 188 | +_C.TEST.RE_RANKING = False |
| 189 | +# Path to trained model |
| 190 | +_C.TEST.WEIGHT = "" |
| 191 | +# Which feature of BNNeck to be used for test, before or after BNNneck, options: 'before' or 'after' |
| 192 | +_C.TEST.NECK_FEAT = 'after' |
| 193 | +# Whether feature is nomalized before test, if yes, it is equivalent to cosine distance |
| 194 | +_C.TEST.FEAT_NORM = 'yes' |
| 195 | + |
| 196 | +# Name for saving the distmat after testing. |
| 197 | +_C.TEST.DIST_MAT = "dist_mat.npy" |
| 198 | +# Whether calculate the eval score option: 'True', 'False' |
| 199 | +_C.TEST.EVAL = False |
| 200 | +# ---------------------------------------------------------------------------- # |
| 201 | +# Misc options |
| 202 | +# ---------------------------------------------------------------------------- # |
| 203 | +# Path to checkpoint and saved log of trained model |
| 204 | +_C.OUTPUT_DIR = "" |
0 commit comments