def add_custom_config(cfg): """This function is used to add in-place custom entries to the default Detectron2 config. For instance : new backbone, new optimizer, new data augmentation etc. Args: cfg (cfgNode): Detectron2 config object """ _C = cfg _C.MODEL.VOVNET = CN() _C.MODEL.VOVNET.CONV_BODY = "V-39-eSE" _C.MODEL.VOVNET.OUT_FEATURES = ["stage2", "stage3", "stage4", "stage5"] # Options: FrozenBN, GN, "SyncBN", "BN" _C.MODEL.VOVNET.NORM = "FrozenBN" _C.MODEL.VOVNET.OUT_CHANNELS = 256 _C.MODEL.VOVNET.BACKBONE_OUT_CHANNELS = 256
def add_coat_config(cfg): """ Add config for CoaT. """ _C = cfg _C.MODEL.COAT = CN() # CoaT model name. _C.MODEL.COAT.NAME = "" # Output features from CoaT backbone. _C.MODEL.COAT.OUT_FEATURES = [ "x1_nocls", "x2_nocls", "x3_nocls", "x4_nocls" ] # Pre-trained weights setting for CoaT. _C.MODEL.COAT.WEIGHTS = "" # Other arguments for CoaT model. _C.MODEL.COAT.MODEL_KWARGS = "{}"
def add_alleria_config(cfg): _C = cfg # ---------------------------------------------------------------------------- # # Data Augmentation # ---------------------------------------------------------------------------- # # mosaic augmentation _C.DATALOADER.MOSAIC_PROB = 0.33 # mix-up augmentation _C.DATALOADER.MIXUP_PROB = 0.34 _C.DATALOADER.CUTOUT_PROB = 0.0 # output prediction and ground truth to image _C.TEST.VISUAL_OUTPUT = False _C.TEST.AUG.NMS_TH = 0.6 # ensemble multi model _C.TEST.ENSEMBLE = CN() _C.TEST.ENSEMBLE.ENABLED = False _C.TEST.ENSEMBLE.NUM = 2 _C.TEST.ENSEMBLE.CONFIGS = ("", )
def add_evaluation_config(cfg: CN): _C = cfg _C.DENSEPOSE_EVALUATION = CN() # evaluator type, possible values: # - "iou": evaluator for models that produce iou data # - "cse": evaluator for models that produce cse data _C.DENSEPOSE_EVALUATION.TYPE = "iou" # storage for DensePose results, possible values: # - "none": no explicit storage, all the results are stored in the # dictionary with predictions, memory intensive; # historically the default storage type # - "ram": RAM storage, uses per-process RAM storage, which is # reduced to a single process storage on later stages, # less memory intensive # - "file": file storage, uses per-process file-based storage, # the least memory intensive, but may create bottlenecks # on file system accesses _C.DENSEPOSE_EVALUATION.STORAGE = "none" # minimum threshold for IOU values: the lower its values is, # the more matches are produced (and the higher the AP score) _C.DENSEPOSE_EVALUATION.MIN_IOU_THRESHOLD = 0.5
def add_attribute_config(cfg): """ Add config for attribute prediction. """ # Whether to have attribute prediction cfg.MODEL.ATTRIBUTE_ON = False # Maximum number of attributes per foreground instance cfg.INPUT.MAX_ATTR_PER_INS = 16 # ------------------------------------------------------------------------ # # Attribute Head # ----------------------------------------------------------------------- # cfg.MODEL.ROI_ATTRIBUTE_HEAD = CN() # Dimension for object class embedding, used in conjunction with # visual features to predict attributes cfg.MODEL.ROI_ATTRIBUTE_HEAD.OBJ_EMBED_DIM = 256 # Dimension of the hidden fc layer of the input visual features cfg.MODEL.ROI_ATTRIBUTE_HEAD.FC_DIM = 512 # Loss weight for attribute prediction, 0.2 is best per analysis cfg.MODEL.ROI_ATTRIBUTE_HEAD.LOSS_WEIGHT = 0.2 # Number of classes for attributes cfg.MODEL.ROI_ATTRIBUTE_HEAD.NUM_CLASSES = 400
def add_detr_config(cfg): """ Add config for DETR. """ cfg.MODEL.DETR = CN() cfg.MODEL.DETR.NUM_CLASSES = 80 cfg.MODEL.DETR.FROZEN_WEIGHTS = '' cfg.MODEL.DETR.GIOU_WEIGHT = 2.0 cfg.MODEL.DETR.L1_WEIGHT = 5.0 cfg.MODEL.DETR.DEEP_SUPERVISION = True cfg.MODEL.DETR.NO_OBJECT_WEIGHT = 0.1 cfg.MODEL.DETR.NHEADS = 8 cfg.MODEL.DETR.DROPOUT = 0.1 cfg.MODEL.DETR.DIM_FEEDFORWARD = 2048 cfg.MODEL.DETR.ENC_LAYERS = 6 cfg.MODEL.DETR.DEC_LAYERS = 6 cfg.MODEL.DETR.PRE_NORM = False cfg.MODEL.DETR.HIDDEN_DIM = 256 cfg.MODEL.DETR.NUM_OBJECT_QUERIES = 100 cfg.SOLVER.OPTIMIZER = 'ADAMW' cfg.SOLVER.BACKBONE_MULTIPLIER = 0.1
def _add_fiberwidth_config(cfg): cfg.MODEL.FIBERWIDTH_ON = True cfg.MODEL.ROI_FIBERWIDTH_HEAD = CN() cfg.MODEL.ROI_FIBERWIDTH_HEAD.NAME = "" # The transition point from L1 to L2 loss. Set to 0.0 to make the loss simply L1. cfg.MODEL.ROI_FIBERWIDTH_HEAD.SMOOTH_L1_BETA = 0.0 cfg.MODEL.ROI_FIBERWIDTH_HEAD.POOLER_RESOLUTION = 14 cfg.MODEL.ROI_FIBERWIDTH_HEAD.POOLER_SAMPLING_RATIO = 0 # Type of pooling operation applied to the incoming feature map for each RoI cfg.MODEL.ROI_FIBERWIDTH_HEAD.POOLER_TYPE = "ROIAlignV2" cfg.MODEL.ROI_FIBERWIDTH_HEAD.NUM_FC = 0 # Hidden layer dimension for FC layers in the RoI fiber width head cfg.MODEL.ROI_FIBERWIDTH_HEAD.FC_DIM = 1024 cfg.MODEL.ROI_FIBERWIDTH_HEAD.NUM_CONV = 0 # Channel dimension for Conv layers in the RoI fiber width head cfg.MODEL.ROI_FIBERWIDTH_HEAD.CONV_DIM = 256 # Normalization method for the convolution layers. # Options: "" (no norm), "GN", "SyncBN". cfg.MODEL.ROI_FIBERWIDTH_HEAD.NORM = "" cfg.MODEL.ROI_FIBERWIDTH_HEAD.LOSS_WEIGHT = 1.0
def add_detr_config(cfg): """ Add config for DETR. """ cfg.MODEL.DETR = CN() cfg.MODEL.DETR.NUM_CLASSES = 80 # FBNet cfg.MODEL.FBNET_V2.OUT_FEATURES = ["trunk3"] # For Segmentation cfg.MODEL.DETR.FROZEN_WEIGHTS = '' # LOSS cfg.MODEL.DETR.DEFORMABLE = False cfg.MODEL.DETR.USE_FOCAL_LOSS = False cfg.MODEL.DETR.CENTERED_POSITION_ENCODIND = False cfg.MODEL.DETR.CLS_WEIGHT = 1.0 cfg.MODEL.DETR.NUM_FEATURE_LEVELS = 4 cfg.MODEL.DETR.GIOU_WEIGHT = 2.0 cfg.MODEL.DETR.L1_WEIGHT = 5.0 cfg.MODEL.DETR.DEEP_SUPERVISION = True cfg.MODEL.DETR.NO_OBJECT_WEIGHT = 0.1 cfg.MODEL.DETR.WITH_BOX_REFINE = False cfg.MODEL.DETR.TWO_STAGE = False # TRANSFORMER cfg.MODEL.DETR.NHEADS = 8 cfg.MODEL.DETR.DROPOUT = 0.1 cfg.MODEL.DETR.DIM_FEEDFORWARD = 2048 cfg.MODEL.DETR.ENC_LAYERS = 6 cfg.MODEL.DETR.DEC_LAYERS = 6 cfg.MODEL.DETR.PRE_NORM = False cfg.MODEL.DETR.HIDDEN_DIM = 256 cfg.MODEL.DETR.NUM_OBJECT_QUERIES = 100 cfg.SOLVER.OPTIMIZER = "ADAMW" cfg.SOLVER.BACKBONE_MULTIPLIER = 0.1
def add_sparsercnn_config(cfg): """ Add config for SparseRCNN. """ cfg.MODEL.SparseRCNN = CN() cfg.MODEL.SparseRCNN.NUM_CLASSES = 8 cfg.MODEL.SparseRCNN.NUM_PROPOSALS = 300 # RCNN Head. cfg.MODEL.SparseRCNN.NHEADS = 8 cfg.MODEL.SparseRCNN.DROPOUT = 0.0 cfg.MODEL.SparseRCNN.DIM_FEEDFORWARD = 2048 cfg.MODEL.SparseRCNN.ACTIVATION = 'relu' cfg.MODEL.SparseRCNN.HIDDEN_DIM = 256 cfg.MODEL.SparseRCNN.NUM_CLS = 1 cfg.MODEL.SparseRCNN.NUM_REG = 3 cfg.MODEL.SparseRCNN.NUM_HEADS = 6 # Dynamic Conv. cfg.MODEL.SparseRCNN.NUM_DYNAMIC = 2 cfg.MODEL.SparseRCNN.DIM_DYNAMIC = 64 # Loss. cfg.MODEL.SparseRCNN.CLASS_WEIGHT = 2.0 cfg.MODEL.SparseRCNN.GIOU_WEIGHT = 2.0 cfg.MODEL.SparseRCNN.L1_WEIGHT = 5.0 cfg.MODEL.SparseRCNN.MASK_WEIGHT = 5.0 #TODO decide weight cfg.MODEL.SparseRCNN.DEEP_SUPERVISION = True cfg.MODEL.SparseRCNN.NO_OBJECT_WEIGHT = 0.1 # Focal Loss. cfg.MODEL.SparseRCNN.USE_FOCAL = True cfg.MODEL.SparseRCNN.ALPHA = 0.25 cfg.MODEL.SparseRCNN.GAMMA = 2.0 cfg.MODEL.SparseRCNN.PRIOR_PROB = 0.01 # Optimizer. cfg.SOLVER.OPTIMIZER = "ADAMW" cfg.SOLVER.BACKBONE_MULTIPLIER = 1.0
def add_detr_config(cfg): """ Add config for DETR. """ cfg.MODEL.DETR = CN() cfg.MODEL.DETR.NUM_CLASSES = 80 # LOSS cfg.MODEL.DETR.GIOU_WEIGHT = 2.0 cfg.MODEL.DETR.L1_WEIGHT = 5.0 cfg.MODEL.DETR.DEEP_SUPERVISION = True cfg.MODEL.DETR.NO_OBJECT_WEIGHT = 0.1 # TRANSFORMER cfg.MODEL.DETR.NHEADS = 8 cfg.MODEL.DETR.DROPOUT = 0.1 cfg.MODEL.DETR.DIM_FEEDFORWARD = 2048 cfg.MODEL.DETR.ENC_LAYERS = 6 cfg.MODEL.DETR.DEC_LAYERS = 6 cfg.MODEL.DETR.PRE_NORM = False cfg.MODEL.DETR.HIDDEN_DIM = 256 cfg.MODEL.DETR.NUM_OBJECT_QUERIES = 100 cfg.SOLVER.OPTIMIZER = "ADAMW" cfg.SOLVER.BACKBONE_MULTIPLIER = 0.1 # Track. cfg.INPUT.ZIP_READ = False cfg.MODEL.DETR.INDEX_FEEDFORWARD = -1 cfg.MODEL.DETR.MAX_FRAME_DIST = 3 cfg.MODEL.DETR.TRACK_ON = False cfg.MODEL.DETR.TRACK_WEIGHT = 1.0 cfg.MODEL.DETR.TRACK_AUG = False cfg.MODEL.DETR.SCORE_THRESH = 0.4 cfg.MODEL.DETR.TRACK_THRESH = 0.5 # cfg.MODEL.DETR.FRAME_WARM = True cfg.MODEL.DETR.FREEZE_DET = False cfg.MODEL.DETR.IGNORE_SAME = False
def setup(args): """ Create configs and perform basic setups. """ cfg = get_cfg() add_tridentnet_config(cfg) cfg.merge_from_file(args.config_file) cfg.merge_from_list(args.opts) cfg.MODEL.PIXEL_MEAN = [28, 28, 28] cfg.MODEL.RPN.IOU_THRESHOLDS = [0.05, 0.3] cfg.MODEL.ROI_HEADS.IOU_THRESHOLDS = [0.3] cfg.MODEL.ANCHOR_GENERATOR.SIZES = [[8, 16, 32, 64, 128]] cfg.SOLVER.MAX_ITER = 1200000 cfg.DATASETS.TRAIN = ('sim_multi_train', ) cfg.DATASETS.TEST = ('sim_multi_test', ) cfg.INPUT.CROP = CN({"ENABLED": True}) cfg.INPUT.CROP.TYPE = "relative_range" cfg.INPUT.CROP.SIZE = [0.75, 0.95] cfg.TEST.EVAL_PERIOD = 50000 cfg.MODEL.WEIGHTS = './output/model_1054999.pth' cfg.SOLVER.BASE_LR = 0.0025 cfg.freeze() default_setup(cfg, args) return cfg
def add_relationnet_config(cfg): """ Add config for relationnet. """ _C = cfg _C.DATASETS.TRAIN = ("voc_2007_trainval",) _C.MODEL.WEIGHTS = "/data171_hdd0/yuhj/Computer_Vision_Practice/RelationNet/output/faster_rcnn/model_final.pth" _C.merge_from_file(os.path.join(os.path.abspath("./configs/relationnet.yaml"))) _C.MODEL.RELATIONNET = CN() _C.MODEL.RELATIONNET.FEAT_DIM = 1024 _C.MODEL.RELATIONNET.LEARN_NMS_TRAIN = True _C.MODEL.RELATIONNET.LEARN_NMS_TEST = False _C.MODEL.RELATIONNET.NUM_RELATION = 1 _C.MODEL.RELATIONNET.POS_EMB_DIM = 64 _C.MODEL.RELATIONNET.ATT_FC_DIM = 16 _C.MODEL.RELATIONNET.ATT_GROUPS = 16 _C.MODEL.RELATIONNET.ATT_DIM = (1024, 1024, 1024) _C.MODEL.RELATIONNET.FIRST_N_TRAIN = 100 _C.MODEL.RELATIONNET.FIRST_N_TEST = 200 _C.MODEL.RELATIONNET.NMS_FC_DIM = 128 _C.MODEL.RELATIONNET.NMS_POS_SCALE = 4.0 _C.MODEL.RELATIONNET.NMS_LOSS_SCALE = 800.0 _C.BBOX_MEANS = (0.0, 0.0, 0.0, 0.0) _C.BBOX_STDS = (0.1, 0.1, 0.2, 0.2)
def append_custom_cfg(cfg): """ カムタムデータセットマッパー用の設定を追加する """ cfg.INPUT.CONTRAST = CN() cfg.INPUT.BRIGHTNESS = CN() cfg.INPUT.SATURATION = CN() cfg.INPUT.EXTENT = CN() cfg.INPUT.ROTATE = CN() cfg.INPUT.SHEAR = CN() cfg.INPUT.CUTOUT = CN() # コントラストの変更 cfg.INPUT.CONTRAST.ENABLED = True cfg.INPUT.CONTRAST.RANGE = (0.5, 1.5) # 明るさの変更 cfg.INPUT.BRIGHTNESS.ENABLED = True cfg.INPUT.BRIGHTNESS.RANGE = (0.8, 1.2) # 彩度の変更 cfg.INPUT.SATURATION.ENABLED = True cfg.INPUT.SATURATION.RANGE = (0.8, 1.2) # アフィン: 位置の変更 cfg.INPUT.EXTENT.ENABLED = True cfg.INPUT.EXTENT.SHIFT_RANGE = (0.2, 0.2) # アフィン: 回転変形 cfg.INPUT.ROTATE.ENABLED = True cfg.INPUT.ROTATE.ANGLE = [-10, 10] # アフィン: せん断変形 cfg.INPUT.SHEAR.ENABLED = True cfg.INPUT.SHEAR.ANGLE_H_RANGE = (-10, 10) cfg.INPUT.SHEAR.ANGLE_V_RANGE = (-10, 10) # カットアウト cfg.INPUT.CUTOUT.ENABLED = True cfg.INPUT.CUTOUT.NUM_HOLE_RANGE = (5, 20) cfg.INPUT.CUTOUT.RADIUS_RANGE = (0.05, 0.15) cfg.INPUT.CUTOUT.COLOR_RANGE = ([0, 255], [0, 255], [0, 255])
from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # Additional Configs # ---------------------------------------------------------------------------- # _C.MODEL.MOBILENET = False _C.MODEL.BACKBONE.ANTI_ALIAS = False _C.MODEL.RESNETS.DEFORM_INTERVAL = 1 _C.INPUT.HFLIP_TRAIN = True _C.INPUT.CROP.CROP_INSTANCE = True # ---------------------------------------------------------------------------- # # FCOS Head # ---------------------------------------------------------------------------- # _C.MODEL.FCOS = CN() # This is the number of foreground classes. _C.MODEL.FCOS.NUM_CLASSES = 80 _C.MODEL.FCOS.IN_FEATURES = ["p3", "p4", "p5", "p6", "p7"] _C.MODEL.FCOS.FPN_STRIDES = [8, 16, 32, 64, 128] _C.MODEL.FCOS.PRIOR_PROB = 0.01 _C.MODEL.FCOS.INFERENCE_TH_TRAIN = 0.05 _C.MODEL.FCOS.INFERENCE_TH_TEST = 0.05 _C.MODEL.FCOS.NMS_TH = 0.6 _C.MODEL.FCOS.PRE_NMS_TOPK_TRAIN = 1000 _C.MODEL.FCOS.PRE_NMS_TOPK_TEST = 1000 _C.MODEL.FCOS.POST_NMS_TOPK_TRAIN = 100 _C.MODEL.FCOS.POST_NMS_TOPK_TEST = 100 _C.MODEL.FCOS.TOP_LEVELS = 2 _C.MODEL.FCOS.NORM = "GN" # Support GN or none
from detectron2.config.defaults import _C from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # MobileNets # ---------------------------------------------------------------------------- # _C.MODEL.MNET = CN() # Output features _C.MODEL.MNET.OUT_FEATURES = ['linear'] # Width mult _C.MODEL.MNET.WIDTH_MULT = 1.0 # ---------------------------------------------------------------------------- # # ClsNets # ---------------------------------------------------------------------------- # _C.MODEL.CLSNET = CN() _C.MODEL.CLSNET.ENABLE = False # classes number _C.MODEL.CLSNET.NUM_CLASSES = 16 # In features _C.MODEL.CLSNET.IN_FEATURES = ['linear'] # Input Size _C.MODEL.CLSNET.INPUT_SIZE = 224 # data directory _C.DATA_DIR_PATH = './data' # weights for criterion _C.MODEL.POS_WEIGHT = [1 for i in range(16)]
from detectron2.config.defaults import _C from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # Additional Configs # ---------------------------------------------------------------------------- # _C.MODEL.MOBILENET = False _C.MODEL.BACKBONE.ANTI_ALIAS = False _C.MODEL.RESNETS.DEFORM_INTERVAL = 1 # ---------------------------------------------------------------------------- # # FCOS Head # ---------------------------------------------------------------------------- # _C.MODEL.FCOS = CN() # This is the number of foreground classes. _C.MODEL.FCOS.NUM_CLASSES = 80 _C.MODEL.FCOS.IN_FEATURES = ["p3", "p4", "p5", "p6", "p7"] _C.MODEL.FCOS.FPN_STRIDES = [8, 16, 32, 64, 128] _C.MODEL.FCOS.PRIOR_PROB = 0.01 _C.MODEL.FCOS.INFERENCE_TH_TRAIN = 0.05 _C.MODEL.FCOS.INFERENCE_TH_TEST = 0.05 _C.MODEL.FCOS.NMS_TH = 0.6 _C.MODEL.FCOS.PRE_NMS_TOPK_TRAIN = 1000 _C.MODEL.FCOS.PRE_NMS_TOPK_TEST = 1000 _C.MODEL.FCOS.POST_NMS_TOPK_TRAIN = 100 _C.MODEL.FCOS.POST_NMS_TOPK_TEST = 100 _C.MODEL.FCOS.TOP_LEVELS = 2 _C.MODEL.FCOS.NORM = "GN" # Support GN or none _C.MODEL.FCOS.USE_SCALE = True
def add_ubteacher_config(cfg): """ Add config for semisupnet. """ _C = cfg _C.TEST.VAL_LOSS = True _C.MODEL.RPN.UNSUP_LOSS_WEIGHT = 1.0 _C.MODEL.RPN.LOSS = "CrossEntropy" _C.MODEL.ROI_HEADS.LOSS = "CrossEntropy" _C.SOLVER.IMG_PER_BATCH_LABEL = 1 _C.SOLVER.IMG_PER_BATCH_UNLABEL = 1 _C.SOLVER.FACTOR_LIST = (1, ) _C.DATASETS.TRAIN_LABEL = ("coco_2017_train", ) _C.DATASETS.TRAIN_UNLABEL = ("coco_2017_train", ) _C.DATASETS.CROSS_DATASET = False _C.TEST.EVALUATOR = "COCOeval" _C.SEMISUPNET = CN() # Output dimension of the MLP projector after `res5` block _C.SEMISUPNET.MLP_DIM = 128 # Semi-supervised training _C.SEMISUPNET.Trainer = "ubteacher" _C.SEMISUPNET.BBOX_THRESHOLD = 0.7 _C.SEMISUPNET.PSEUDO_BBOX_SAMPLE = "thresholding" _C.SEMISUPNET.TEACHER_UPDATE_ITER = 1 _C.SEMISUPNET.BURN_UP_STEP = 12000 _C.SEMISUPNET.EMA_KEEP_RATE = 0.0 _C.SEMISUPNET.UNSUP_LOSS_WEIGHT = 4.0 _C.SEMISUPNET.SUP_LOSS_WEIGHT = 0.5 _C.SEMISUPNET.LOSS_WEIGHT_TYPE = "standard" _C.SEMISUPNET.SUPERVISED_CROSS_LEVEL = False _C.SEMISUPNET.PSEUDO_LABEL_CROSS_LEVEL = False # dataloader # supervision level _C.DATALOADER.SUP_PERCENT = 100.0 # 5 = 5% dataset as labeled set _C.DATALOADER.RANDOM_DATA_SEED = 0 # random seed to read data _C.DATALOADER.RANDOM_DATA_SEED_PATH = "dataseed/COCO_supervision.txt" _C.CONSISTENCY = CN() _C.CONSISTENCY.ROI_LEVEL = True _C.CONSISTENCY.APPLY_CLS = True _C.CONSISTENCY.APPLY_REG = True _C.CONSISTENCY.PAD_TYPE = 'ratio' _C.CONSISTENCY.MIN_PROPOSAL = 512 _C.CONSISTENCY.RAMP_END = 10000 _C.CONSISTENCY.CLS = 'MSE' _C.CONSISTENCY.REG = 'MSE' _C.CONSISTENCY.START = 0 _C.CONSISTENCY.END = 80000 _C.WEIGHT_SCHEDULE = CN() _C.WEIGHT_SCHEDULE.REWEIGHT = False _C.WEIGHT_SCHEDULE.T1 = 40000 _C.WEIGHT_SCHEDULE.T2 = 120000 _C.WEIGHT_SCHEDULE.W1 = 0.5 _C.WEIGHT_SCHEDULE.W2 = 0.3 _C.EMAMODEL = CN() _C.EMAMODEL.SUP_CONSIST = True
from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # Additional Configs # ---------------------------------------------------------------------------- # _C.MODEL.MOBILENET = False _C.MODEL.BACKBONE.ANTI_ALIAS = False _C.MODEL.RESNETS.DEFORM_INTERVAL = 1 _C.INPUT.HFLIP_TRAIN = True _C.INPUT.CROP.CROP_INSTANCE = True # ---------------------------------------------------------------------------- # # FCOS Head # ---------------------------------------------------------------------------- # _C.MODEL.FCOS = CN() # This is the number of foreground classes. _C.MODEL.FCOS.NUM_CLASSES = 80 _C.MODEL.FCOS.IN_FEATURES = ["p3", "p4", "p5", "p6", "p7"] _C.MODEL.FCOS.FPN_STRIDES = [8, 16, 32, 64, 128] _C.MODEL.FCOS.PRIOR_PROB = 0.01 _C.MODEL.FCOS.INFERENCE_TH_TRAIN = 0.05 _C.MODEL.FCOS.INFERENCE_TH_TEST = 0.05 _C.MODEL.FCOS.NMS_TH = 0.6 _C.MODEL.FCOS.PRE_NMS_TOPK_TRAIN = 1000 _C.MODEL.FCOS.PRE_NMS_TOPK_TEST = 1000 _C.MODEL.FCOS.POST_NMS_TOPK_TRAIN = 100 _C.MODEL.FCOS.POST_NMS_TOPK_TEST = 100 _C.MODEL.FCOS.TOP_LEVELS = 2 _C.MODEL.FCOS.NORM = "GN" # Support GN or none
# ----------------------------------------------------------------------------- # Convention about Training / Test specific parameters # ----------------------------------------------------------------------------- # Whenever an argument can be either used for training or for testing, the # corresponding name will be post-fixed by a _TRAIN for a training parameter, # or _TEST for a test-specific parameter. # For example, the number of images during training will be # IMAGES_PER_BATCH_TRAIN, while the number of images for testing will be # IMAGES_PER_BATCH_TEST # ----------------------------------------------------------------------------- # Config definition # ----------------------------------------------------------------------------- _C = CN() # The version number, to upgrade from old configs to new ones if any # changes happen. It's recommended to keep a VERSION in your config file. _C.VERSION = 2 _C.MODEL = CN() _C.MODEL.LOAD_PROPOSALS = False _C.MODEL.MASK_ON = False _C.MODEL.KEYPOINT_ON = False _C.MODEL.DEVICE = "cuda" _C.MODEL.META_ARCHITECTURE = "GeneralizedRCNN" # Path (possibly with schema like catalog:// or detectron2://) to a checkpoint file # to be loaded to the model. You can find available models in the model zoo. _C.MODEL.WEIGHTS = ""
from detectron2.config.defaults import _C from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # Additional Configs # ---------------------------------------------------------------------------- # _C.MODEL.MOBILENET = False # ---------------------------------------------------------------------------- # # FCOS Head # ---------------------------------------------------------------------------- # _C.MODEL.FCOS = CN() # This is the number of foreground classes. _C.MODEL.FCOS.NUM_CLASSES = 80 _C.MODEL.FCOS.IN_FEATURES = ["p3", "p4", "p5", "p6", "p7"] _C.MODEL.FCOS.FPN_STRIDES = [8, 16, 32, 64, 128] _C.MODEL.FCOS.PRIOR_PROB = 0.01 _C.MODEL.FCOS.INFERENCE_TH_TRAIN = 0.05 _C.MODEL.FCOS.INFERENCE_TH_TEST = 0.05 _C.MODEL.FCOS.NMS_TH = 0.6 _C.MODEL.FCOS.PRE_NMS_TOPK_TRAIN = 1000 _C.MODEL.FCOS.PRE_NMS_TOPK_TEST = 1000 _C.MODEL.FCOS.POST_NMS_TOPK_TRAIN = 100 _C.MODEL.FCOS.POST_NMS_TOPK_TEST = 100 _C.MODEL.FCOS.TOP_LEVELS = 2 _C.MODEL.FCOS.NORM = "GN" # Support GN or none _C.MODEL.FCOS.USE_SCALE = True # Multiply centerness before threshold # This will affect the final performance by about 0.05 AP but save some time
def add_gambler_config(cfg): """ Add config for gambler/ gambler-detection head. """ _C = cfg _C.MODEL.GAMBLER_ON = True _C.MODEL.GAMBLER_HEAD = CN() # VARIANTS: SimpleGambler - UnetGambler _C.MODEL.GAMBLER_HEAD.NAME = "UnetGambler" # If this option is turned on, pretrained model will be loaded into gambler _C.MODEL.GAMBLER_HEAD.LOAD_PRETRAINED_GAMBLER = False # Loading pretrained weights for the gambler from this location _C.MODEL.GAMBLER_HEAD.WEIGHTS = "./output/gambler/focal_plus_gambler/gambler_models/model_0042749.pth" # number of iterations the gambler is trained before the detector is trained _C.MODEL.GAMBLER_HEAD.GAMBLER_ITERATIONS = 100 # number of iterations the detector is trained before the gambler is trained _C.MODEL.GAMBLER_HEAD.DETECTOR_ITERATIONS = 200 # VARIANTS: BCHW(input to gambler is (B, C, H, W)), BCAHW (input to gambler is (B, CxA, H, W)) _C.MODEL.GAMBLER_HEAD.GAMBLER_INPUT = "BCAHW" # VARIANTS: B1HW BCHW BAHW BCAHW _C.MODEL.GAMBLER_HEAD.GAMBLER_OUTPUT = "BAHW" # Number of input channels to the gambler module (num_classes + 3 (input channel RGB)) _C.MODEL.GAMBLER_HEAD.GAMBLER_IN_CHANNELS = 883 # 3(scales) x 80(classes) + 3(RGB) # Number of output channels of the gambler module (desired betting map channels) _C.MODEL.GAMBLER_HEAD.GAMBLER_OUT_CHANNELS = 11 # Hyperparameter lambda that multiplies the gambler loss _C.MODEL.GAMBLER_HEAD.GAMBLER_KAPPA = 2200 # Hyperparameter lambda that multiplies the regression loss _C.MODEL.GAMBLER_HEAD.REGRESSION_LAMBDA = 1 # Hyperparameter lambda that multiplies the gambler loss from outside _C.MODEL.GAMBLER_HEAD.GAMBLER_OUTSIDE_LAMBDA = 1.0 _C.MODEL.GAMBLER_HEAD.GAMBLER_TEMPERATURE = 0.03 # classification loss used in the gambler can be either "sigmoid" or "focal" _C.MODEL.GAMBLER_HEAD.GAMBLER_LOSS_MODE = "focal" # detector loss can be either cls+reg-gambler or weighted_cls_with_gambler+reg _C.MODEL.GAMBLER_HEAD.DETECTOR_LOSS_MODE = "cls+reg-gambler" # normalizing the weights of the gambler, turned off for sanity check that gambler is learning _C.MODEL.GAMBLER_HEAD.NORMALIZE = True # adjusting the range of the data given to the gambler _C.MODEL.GAMBLER_HEAD.DATA_RANGE = [-128, 128] # If True, in unet gambler upsampling is done with bilinear interpolation, o.w. with TransposeConv _C.MODEL.GAMBLER_HEAD.BILINEAR_UPSAMPLING = True # original image is "downsample" or "conv" and then concatenated with predictions _C.MODEL.GAMBLER_HEAD.IMAGE_MODE = "downsample" # If image mode is downsample, image_channels has to be 3, otherwise it's a hyperparam _C.MODEL.GAMBLER_HEAD.IMAGE_CHANNELS = 3 # Number of fixed channels going into gambler _C.MODEL.GAMBLER_HEAD.FIXED_CHANNEL = 32 # Number of classes predicted by detector _C.MODEL.GAMBLER_HEAD.NUM_CLASSES = 80 # Feature layer sizes going into gambler _C.MODEL.GAMBLER_HEAD.IN_LAYERS = [80, 40, 20, 10, 5] # if True all images are saved in "images" folder, otherwise only in tensorboard _C.MODEL.GAMBLER_HEAD.SAVE_VIS_FILES = False # {{{He/Xavier}_{uniform/normal}}/random}_{unet/unet+prepost}_{bias0/biasrand} _C.MODEL.GAMBLER_HEAD.INIT = "random" # prior probability on the last layer of gambler _C.MODEL.GAMBLER_HEAD.PRIOR_PROB = 0.01 # gambler optimizer: sgd or adam _C.MODEL.GAMBLER_HEAD.OPTIMIZER = "sgd" # bettingmap goes to the power of gamma to control focus on bets, if 0 -> normal bce loss _C.MODEL.GAMBLER_HEAD.GAMBLER_GAMMA = 1.0 # The period (in terms of steps) for minibatch visualization at train time. # Set to 0 to disable. _C.MODEL.GAMBLER_HEAD.VIS_PERIOD = 1000 # initialize all these values to the default of the detector but can be changed later _C.MODEL.GAMBLER_HEAD.BASE_LR = cfg.SOLVER.BASE_LR _C.MODEL.GAMBLER_HEAD.BIAS_LR_FACTOR = cfg.SOLVER.BIAS_LR_FACTOR _C.MODEL.GAMBLER_HEAD.WEIGHT_DECAY = _C.SOLVER.WEIGHT_DECAY _C.MODEL.GAMBLER_HEAD.WEIGHT_DECAY_NORM = _C.SOLVER.WEIGHT_DECAY_NORM _C.MODEL.GAMBLER_HEAD.WEIGHT_DECAY_BIAS = _C.SOLVER.WEIGHT_DECAY_BIAS _C.MODEL.GAMBLER_HEAD.MOMENTUM = _C.SOLVER.MOMENTUM
def add_boundary_preserving_config(cfg): cfg.MODEL.BOUNDARY_MASK_HEAD = CN() cfg.MODEL.BOUNDARY_MASK_HEAD.POOLER_RESOLUTION = 28 cfg.MODEL.BOUNDARY_MASK_HEAD.IN_FEATURES = ("p2", ) cfg.MODEL.BOUNDARY_MASK_HEAD.NUM_CONV = 2
def add_centernet_config(cfg): """ Add config for tridentnet. """ # centernet config cfg.MODEL.CENTERNET = CN() cfg.MODEL.CENTERNET.IN_FEATURES = "res5" cfg.MODEL.CENTERNET.NUM_CLASSES = 80 cfg.MODEL.CENTERNET.BIAS_VALUE = -2.19 cfg.MODEL.CENTERNET.DOWN_SCALE = 4 cfg.MODEL.CENTERNET.MIN_OVERLAP = 0.7 cfg.MODEL.CENTERNET.TENSOR_DIM = 128 cfg.MODEL.CENTERNET.BOX_MINSIZE = 1e-5 cfg.MODEL.CENTERNET.SCORE_THRESH_TEST = 0.05 cfg.MODEL.CENTERNET.DECONV = CN() cfg.MODEL.CENTERNET.DECONV.CHANNEL = [256, 128, 64] cfg.MODEL.CENTERNET.DECONV.KERNEL = [4, 4, 4] cfg.MODEL.CENTERNET.DECONV.DEFORM = False cfg.MODEL.CENTERNET.DECONV.DEFORM_MODULATED = False # cfg.MODEL.CENTERNET.RESIZE_TYPE = "ResizeShortestEdge" # cfg.MODEL.CENTERNET.TRAIN_PIPELINES = [ # # ("CenterAffine", dict(boarder=128, output_size=(512, 512), random_aug=True)), # ("RandomFlip", dict()), # ("RandomBrightness", dict(intensity_min=0.6, intensity_max=1.4)), # ("RandomContrast", dict(intensity_min=0.6, intensity_max=1.4)), # ("RandomSaturation", dict(intensity_min=0.6, intensity_max=1.4)), # ("RandomLighting", dict(scale=0.1)), # ] cfg.MODEL.CENTERNET.TEST_PIPELINES = [] cfg.MODEL.CENTERNET.LOSS = CN() cfg.MODEL.CENTERNET.LOSS.HM_WEIGHT = 1 cfg.MODEL.CENTERNET.LOSS.WH_WEIGHT = 0.1 cfg.MODEL.CENTERNET.LOSS.REG_WEIGHT = 1 cfg.MODEL.CENTERNET.LOSS.NORM_WH = False cfg.MODEL.CENTERNET.LOSS.SKIP_LOSS = False cfg.MODEL.CENTERNET.LOSS.SKIP_WEIGHT = 1.0 cfg.MODEL.CENTERNET.LOSS.MSE = False cfg.MODEL.CENTERNET.LOSS.IGNORE_UNLABEL = False cfg.MODEL.CENTERNET.LOSS.COMMUNISM = CN() cfg.MODEL.CENTERNET.LOSS.COMMUNISM.ENABLE = False cfg.MODEL.CENTERNET.LOSS.COMMUNISM.CLS_LOSS = 1.5 cfg.MODEL.CENTERNET.LOSS.COMMUNISM.WH_LOSS = 0.3 cfg.MODEL.CENTERNET.LOSS.COMMUNISM.OFF_LOSS = 0.1 cfg.MODEL.CENTERNET.IMGAUG_PROB = 2.0 # optim and min_lr(for cosine schedule) cfg.SOLVER.MIN_LR = 1e-8 cfg.SOLVER.OPTIM_NAME = "SGD" cfg.SOLVER.COSINE_DECAY_ITER = 0.7 # Knowledge Distill cfg.MODEL.CENTERNET.KD = CN() cfg.MODEL.CENTERNET.KD.ENABLED = False cfg.MODEL.CENTERNET.KD.TEACHER_CFG = [ "None", ] cfg.MODEL.CENTERNET.KD.TEACHER_WEIGTHS = [ "None", ] cfg.MODEL.CENTERNET.KD.KD_WEIGHT = [ 10.0, ] cfg.MODEL.CENTERNET.KD.KD_CLS_WEIGHT = [ 1.0, ] cfg.MODEL.CENTERNET.KD.KD_WH_WEIGHT = [ 1.0, ] cfg.MODEL.CENTERNET.KD.KD_REG_WEIGHT = [ 0.1, ] cfg.MODEL.CENTERNET.KD.KD_CLS_INDEX = [ 1, ] cfg.MODEL.CENTERNET.KD.NORM_WH = [ False, ] cfg.MODEL.CENTERNET.KD.KD_WITHOUT_LABEL = False # input config cfg.INPUT.FORMAT = "RGB"
from detectron2.config.defaults import _C from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # Additional Configs # ---------------------------------------------------------------------------- # _C.MODEL.MOBILENET = False _C.MODEL.USE_VOVNET = False # ---------------------------------------------------------------------------- # # MY CONFIG (ZC) # ---------------------------------------------------------------------------- # _C.MODEL.DANCE = CN() # Channeling the input for mask_pred used for model evaluation # Use NO to avoid error during evaluation when turn MASK_ON but no mask_pred output. _C.MODEL.DANCE.MASK_IN = "OCT_RLE" # {'BOX', 'OCT_BIT', 'OCT_RLE', 'MASK', 'NO'} _C.MODEL.DANCE.SEMANTIC_FILTER = False _C.MODEL.DANCE.SEMANTIC_FILTER_TH = 0.1 _C.MODEL.DANCE.ROI_SIZE = 28 _C.MODEL.DANCE.RE_COMP_BOX = False # ---------------------------------------------------------------------------- # # Deformable Convolution Head (ZC) # ---------------------------------------------------------------------------- # _C.MODEL.DEFORM_HEAD = CN() _C.MODEL.DEFORM_HEAD.ON = False _C.MODEL.DEFORM_HEAD.NUM_CONVS = 256 _C.MODEL.DEFORM_HEAD.NORM = "GN" _C.MODEL.DEFORM_HEAD.USE_MODULATED = False
_C = d2config() # -------------------------------------------------------------------------------# # Required by SlenderDet # -------------------------------------------------------------------------------# _C.DEBUG = False _C.USE_NORI = False _C.NEED_MASKS = False _C.DATALOADER.OSS_ROOT = "s3://detection/" _C.NORI_PATH = "s3://detection/datasets/coco/" _C.REDIS = CN() _C.REDIS.HOST = "10.124.171.195" _C.REDIS.PORT = 6379 _C.REDIS.DB = 0 # Matcer Type ["Origin", "TopK"] _C.MODEL.RPN.MATCHER = CN() _C.MODEL.RPN.MATCHER.TYPE = "Origin" # default top k is 10 _C.MODEL.RPN.MATCHER.TOPK = 10 _C.MODEL.PROPOSAL_GENERATOR.IN_FEATURES = ["p5"] _C.MODEL.PROPOSAL_GENERATOR.NUM_POINTS = 9 _C.MODEL.PROPOSAL_GENERATOR.SIZES = [8, 16, 32, 64, 128] _C.MODEL.PROPOSAL_GENERATOR.SAMPLE_MODE = "point"
from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # Additional Configs # ---------------------------------------------------------------------------- # _C.MODEL.MOBILENET = False _C.MODEL.BACKBONE.ANTI_ALIAS = False _C.MODEL.RESNETS.DEFORM_INTERVAL = 1 _C.INPUT.HFLIP_TRAIN = True _C.INPUT.CROP.CROP_INSTANCE = True # ---------------------------------------------------------------------------- # # FCOS Head # ---------------------------------------------------------------------------- # _C.MODEL.FCOS = CN() # This is the number of foreground classes. _C.MODEL.FCOS.NUM_CLASSES = 80 _C.MODEL.FCOS.IN_FEATURES = ["p3", "p4", "p5", "p6", "p7"] _C.MODEL.FCOS.FPN_STRIDES = [8, 16, 32, 64, 128] _C.MODEL.FCOS.PRIOR_PROB = 0.01 _C.MODEL.FCOS.INFERENCE_TH_TRAIN = 0.05 _C.MODEL.FCOS.INFERENCE_TH_TEST = 0.05 _C.MODEL.FCOS.NMS_TH = 0.6 _C.MODEL.FCOS.PRE_NMS_TOPK_TRAIN = 1000 _C.MODEL.FCOS.PRE_NMS_TOPK_TEST = 1000 _C.MODEL.FCOS.POST_NMS_TOPK_TRAIN = 100 _C.MODEL.FCOS.POST_NMS_TOPK_TEST = 100 _C.MODEL.FCOS.TOP_LEVELS = 2 _C.MODEL.FCOS.NORM = "GN" # Support GN or none
def add_centernet_config(cfg): _C = cfg _C.MODEL.CENTERNET = CN() _C.MODEL.CENTERNET.NUM_CLASSES = 80 _C.MODEL.CENTERNET.IN_FEATURES = ["p3", "p4", "p5", "p6", "p7"] _C.MODEL.CENTERNET.FPN_STRIDES = [8, 16, 32, 64, 128] _C.MODEL.CENTERNET.PRIOR_PROB = 0.01 _C.MODEL.CENTERNET.INFERENCE_TH = 0.05 _C.MODEL.CENTERNET.CENTER_NMS = False _C.MODEL.CENTERNET.NMS_TH_TRAIN = 0.6 _C.MODEL.CENTERNET.NMS_TH_TEST = 0.6 _C.MODEL.CENTERNET.PRE_NMS_TOPK_TRAIN = 1000 _C.MODEL.CENTERNET.POST_NMS_TOPK_TRAIN = 100 _C.MODEL.CENTERNET.PRE_NMS_TOPK_TEST = 1000 _C.MODEL.CENTERNET.POST_NMS_TOPK_TEST = 100 _C.MODEL.CENTERNET.NORM = "GN" _C.MODEL.CENTERNET.USE_DEFORMABLE = False _C.MODEL.CENTERNET.NUM_CLS_CONVS = 4 _C.MODEL.CENTERNET.NUM_BOX_CONVS = 4 _C.MODEL.CENTERNET.NUM_SHARE_CONVS = 0 _C.MODEL.CENTERNET.LOC_LOSS_TYPE = 'giou' _C.MODEL.CENTERNET.SIGMOID_CLAMP = 1e-4 _C.MODEL.CENTERNET.HM_MIN_OVERLAP = 0.8 _C.MODEL.CENTERNET.MIN_RADIUS = 4 _C.MODEL.CENTERNET.SOI = [[0, 80], [64, 160], [128, 320], [256, 640], [512, 10000000]] _C.MODEL.CENTERNET.POS_WEIGHT = 1. _C.MODEL.CENTERNET.NEG_WEIGHT = 1. _C.MODEL.CENTERNET.REG_WEIGHT = 2. _C.MODEL.CENTERNET.HM_FOCAL_BETA = 4 _C.MODEL.CENTERNET.HM_FOCAL_ALPHA = 0.25 _C.MODEL.CENTERNET.LOSS_GAMMA = 2.0 _C.MODEL.CENTERNET.WITH_AGN_HM = False _C.MODEL.CENTERNET.ONLY_PROPOSAL = False _C.MODEL.CENTERNET.AS_PROPOSAL = False _C.MODEL.CENTERNET.IGNORE_HIGH_FP = -1. _C.MODEL.CENTERNET.MORE_POS = False _C.MODEL.CENTERNET.MORE_POS_THRESH = 0.2 _C.MODEL.CENTERNET.MORE_POS_TOPK = 9 _C.MODEL.CENTERNET.NOT_NORM_REG = True _C.MODEL.CENTERNET.NOT_NMS = False _C.MODEL.ROI_BOX_HEAD.USE_SIGMOID_CE = False _C.MODEL.ROI_BOX_HEAD.PRIOR_PROB = 0.01 _C.MODEL.ROI_BOX_HEAD.USE_EQL_LOSS = False _C.MODEL.ROI_BOX_HEAD.CAT_FREQ_PATH = \ 'datasets/lvis/lvis_v1_train_cat_info.json' _C.MODEL.ROI_BOX_HEAD.EQL_FREQ_CAT = 200 _C.MODEL.ROI_BOX_HEAD.USE_FED_LOSS = False _C.MODEL.ROI_BOX_HEAD.FED_LOSS_NUM_CAT = 50 _C.MODEL.ROI_BOX_HEAD.FED_LOSS_FREQ_WEIGHT = 0.5 _C.MODEL.ROI_BOX_HEAD.MULT_PROPOSAL_SCORE = False _C.MODEL.BIFPN = CN() _C.MODEL.BIFPN.NUM_LEVELS = 5 _C.MODEL.BIFPN.NUM_BIFPN = 6 _C.MODEL.BIFPN.NORM = 'GN' _C.MODEL.BIFPN.OUT_CHANNELS = 160 _C.MODEL.BIFPN.SEPARABLE_CONV = False _C.MODEL.DLA = CN() _C.MODEL.DLA.OUT_FEATURES = ['dla2'] _C.MODEL.DLA.USE_DLA_UP = True _C.MODEL.DLA.NUM_LAYERS = 34 _C.MODEL.DLA.MS_OUTPUT = False _C.MODEL.DLA.NORM = 'BN' _C.MODEL.DLA.DLAUP_IN_FEATURES = ['dla3', 'dla4', 'dla5'] _C.MODEL.DLA.DLAUP_NODE = 'conv' _C.SOLVER.RESET_ITER = False _C.SOLVER.TRAIN_ITER = -1 _C.INPUT.CUSTOM_AUG = '' _C.INPUT.TRAIN_SIZE = 640 _C.INPUT.TEST_SIZE = 640 _C.INPUT.SCALE_RANGE = (0.1, 2.) # 'default' for fixed short/ long edge, 'square' for max size=INPUT.SIZE _C.INPUT.TEST_INPUT_TYPE = 'default' _C.DEBUG = False _C.SAVE_DEBUG = False _C.SAVE_PTH = False _C.VIS_THRESH = 0.3 _C.DEBUG_SHOW_NAME = False
"""Default config for contour project.""" from detectron2.config.defaults import _C from detectron2.config import CfgNode as CN # ---------------------------------------------------------------------------- # # Additional Configs # ---------------------------------------------------------------------------- # _C.INPUT.MASK_FORMAT = "bitmask" # alternative: "bitmask" # ---------------------------------------------------------------------------- # # FPN Block # ---------------------------------------------------------------------------- # _C.MODEL.FPN_BLOCK = CN() _C.MODEL.FPN_BLOCK.NAME = "FPNBlock" _C.MODEL.FPN_BLOCK.IN_FEATURES = ["p2", "p3", "p4", "p5"] # Number of channels in the 3x3 convs inside FPN heads. _C.MODEL.FPN_BLOCK.CONVS_DIM = 128 # Outputs from FPN heads are up-scaled to the COMMON_STRIDE stride. _C.MODEL.FPN_BLOCK.COMMON_STRIDE = 4 # Normalization method for the convolution layers. Options: "" (no norm), "GN". _C.MODEL.FPN_BLOCK.NORM = "GN" # ---------------------------------------------------------------------------- # # HED Decoder # ---------------------------------------------------------------------------- # _C.MODEL.HED_DECODER = CN() _C.MODEL.HED_DECODER.NAME = "HedDecoder" _C.MODEL.HED_DECODER.IN_FEATURES = ["res2", "res3", "res4", "res5"] _C.MODEL.HED_DECODER.LOSS_WEIGHT = 1.0 _C.MODEL.HED_DECODER.NUM_CLASSES = 1 # 9 # (8 Stuff + 1 background)
def add_densepose_head_config(cfg: CN): """ Add config for densepose head. """ _C = cfg _C.MODEL.DENSEPOSE_ON = True _C.MODEL.ROI_DENSEPOSE_HEAD = CN() _C.MODEL.ROI_DENSEPOSE_HEAD.NAME = "" _C.MODEL.ROI_DENSEPOSE_HEAD.NUM_STACKED_CONVS = 8 # Number of parts used for point labels _C.MODEL.ROI_DENSEPOSE_HEAD.NUM_PATCHES = 24 _C.MODEL.ROI_DENSEPOSE_HEAD.DECONV_KERNEL = 4 _C.MODEL.ROI_DENSEPOSE_HEAD.CONV_HEAD_DIM = 512 _C.MODEL.ROI_DENSEPOSE_HEAD.CONV_HEAD_KERNEL = 3 _C.MODEL.ROI_DENSEPOSE_HEAD.UP_SCALE = 2 _C.MODEL.ROI_DENSEPOSE_HEAD.HEATMAP_SIZE = 112 _C.MODEL.ROI_DENSEPOSE_HEAD.POOLER_TYPE = "ROIAlignV2" _C.MODEL.ROI_DENSEPOSE_HEAD.POOLER_RESOLUTION = 28 _C.MODEL.ROI_DENSEPOSE_HEAD.POOLER_SAMPLING_RATIO = 2 _C.MODEL.ROI_DENSEPOSE_HEAD.NUM_COARSE_SEGM_CHANNELS = 2 # 15 or 2 # Overlap threshold for an RoI to be considered foreground (if >= FG_IOU_THRESHOLD) _C.MODEL.ROI_DENSEPOSE_HEAD.FG_IOU_THRESHOLD = 0.7 # Loss weights for annotation masks.(14 Parts) _C.MODEL.ROI_DENSEPOSE_HEAD.INDEX_WEIGHTS = 5.0 # Loss weights for surface parts. (24 Parts) _C.MODEL.ROI_DENSEPOSE_HEAD.PART_WEIGHTS = 1.0 # Loss weights for UV regression. _C.MODEL.ROI_DENSEPOSE_HEAD.POINT_REGRESSION_WEIGHTS = 0.01 # Coarse segmentation is trained using instance segmentation task data _C.MODEL.ROI_DENSEPOSE_HEAD.COARSE_SEGM_TRAINED_BY_MASKS = False # For Decoder _C.MODEL.ROI_DENSEPOSE_HEAD.DECODER_ON = True _C.MODEL.ROI_DENSEPOSE_HEAD.DECODER_NUM_CLASSES = 256 _C.MODEL.ROI_DENSEPOSE_HEAD.DECODER_CONV_DIMS = 256 _C.MODEL.ROI_DENSEPOSE_HEAD.DECODER_NORM = "" _C.MODEL.ROI_DENSEPOSE_HEAD.DECODER_COMMON_STRIDE = 4 # For DeepLab head _C.MODEL.ROI_DENSEPOSE_HEAD.DEEPLAB = CN() _C.MODEL.ROI_DENSEPOSE_HEAD.DEEPLAB.NORM = "GN" _C.MODEL.ROI_DENSEPOSE_HEAD.DEEPLAB.NONLOCAL_ON = 0 # Predictor class name, must be registered in DENSEPOSE_PREDICTOR_REGISTRY # Some registered predictors: # "DensePoseChartPredictor": predicts segmentation and UV coordinates for predefined charts # "DensePoseChartWithConfidencePredictor": predicts segmentation, UV coordinates # and associated confidences for predefined charts (default) _C.MODEL.ROI_DENSEPOSE_HEAD.PREDICTOR_NAME = "DensePoseChartWithConfidencePredictor" # Loss class name, must be registered in DENSEPOSE_LOSS_REGISTRY # Some registered losses: # "DensePoseChartLoss": loss for chart-based models that estimate # segmentation and UV coordinates # "DensePoseChartWithConfidenceLoss": loss for chart-based models that estimate # segmentation, UV coordinates and the corresponding confidences (default) _C.MODEL.ROI_DENSEPOSE_HEAD.LOSS_NAME = "DensePoseChartWithConfidenceLoss" # Confidences # Enable learning UV confidences (variances) along with the actual values _C.MODEL.ROI_DENSEPOSE_HEAD.UV_CONFIDENCE = CN({"ENABLED": False}) # UV confidence lower bound _C.MODEL.ROI_DENSEPOSE_HEAD.UV_CONFIDENCE.EPSILON = 0.01 # Enable learning segmentation confidences (variances) along with the actual values _C.MODEL.ROI_DENSEPOSE_HEAD.SEGM_CONFIDENCE = CN({"ENABLED": False}) # Segmentation confidence lower bound _C.MODEL.ROI_DENSEPOSE_HEAD.SEGM_CONFIDENCE.EPSILON = 0.01 # Statistical model type for confidence learning, possible values: # - "iid_iso": statistically independent identically distributed residuals # with isotropic covariance # - "indep_aniso": statistically independent residuals with anisotropic # covariances _C.MODEL.ROI_DENSEPOSE_HEAD.UV_CONFIDENCE.TYPE = "iid_iso" # List of angles for rotation in data augmentation during training _C.INPUT.ROTATION_ANGLES = [0] _C.TEST.AUG.ROTATION_ANGLES = () # Rotation TTA add_densepose_head_cse_config(cfg)
def add_troi_config(cfg): """ Add config for Transformer-ROI. """ cfg.MODEL.SYNC_BN = True # Deactivate SyncBatchNorm with single GPU cfg.MODEL.REINITIALIZE_BOX_PREDICTOR = False cfg.MODEL.ROI_BOX_HEAD.USE_COSINE = False cfg.MODEL.RPN.NUM_CONV = 1 cfg.MODEL.FPN.NUM_REPEATS = 2 cfg.MODEL.ROI_HEADS.SOFT_NMS_ENABLED = False cfg.MODEL.ROI_HEADS.SOFT_NMS_METHOD = "linear" cfg.MODEL.ROI_HEADS.SOFT_NMS_SIGMA = 0.5 cfg.MODEL.ROI_HEADS.SOFT_NMS_PRUNE = 0.001 cfg.MODEL.ROI_HEADS.TTA_NMS_THRESH_TEST = 0.5 cfg.MODEL.ROI_HEADS.TTA_SCORE_THRESH_TEST = 0.001 cfg.MODEL.ROI_HEADS.TTA_SOFT_NMS_ENABLED = False cfg.MODEL.ROI_HEADS.TTA_SOFT_NMS_METHOD = "linear" cfg.MODEL.ROI_HEADS.TTA_SOFT_NMS_SIGMA = 0.5 cfg.MODEL.ROI_HEADS.TTA_SOFT_NMS_PRUNE = 0.001 cfg.MODEL.MY_ROI_BOX_HEAD = CN() cfg.MODEL.MY_ROI_BOX_HEAD.D_MODEL = 512 cfg.MODEL.MY_ROI_BOX_HEAD.NHEAD = 8 cfg.MODEL.MY_ROI_BOX_HEAD.NUM_ENCODER_LAYERS = 6 cfg.MODEL.MY_ROI_BOX_HEAD.NUM_DECODER_LAYERS = 6 cfg.MODEL.MY_ROI_BOX_HEAD.DIM_FEEDFORWARD = 2048 cfg.MODEL.MY_ROI_BOX_HEAD.DROPOUT = 0.1 cfg.MODEL.MY_ROI_BOX_HEAD.ACTIVATION = "relu" cfg.MODEL.MY_ROI_BOX_HEAD.NORMALIZE_BEFORE = True cfg.MODEL.MY_ROI_BOX_HEAD.USE_ENCODER_DECODER = False cfg.MODEL.MY_ROI_BOX_HEAD.USE_POSITION_ENCODING = False cfg.MODEL.MY_ROI_BOX_HEAD.USE_LINEAR_ATTENTION = False cfg.MODEL.MY_ROI_BOX_HEAD.NUM_FC = 1 cfg.MODEL.MY_ROI_BOX_HEAD.FC_DIM = 1024 cfg.MODEL.MY_ROI_BOX_HEAD.NUM_CONV = 0 cfg.MODEL.MY_ROI_BOX_HEAD.CONV_DIM = 256 cfg.MODEL.MY_ROI_BOX_HEAD.NUM_SELF_ATTENTION = 0 cfg.MODEL.MY_ROI_BOX_HEAD.SELF_ATTENTION_DIM = 256 cfg.MODEL.ROI_BOX_HEAD.ENCODER_FEATURE = "p5" cfg.MODEL.ROI_BOX_HEAD.EOS_COEF = 0.1 cfg.MODEL.ROI_BOX_HEAD.ADD_NOISE_TO_PROPOSALS = False cfg.MODEL.ROI_BOX_HEAD.USE_OBJ_LOSS = False cfg.MODEL.ROI_BOX_HEAD.L1_WEIGHT = 1.0 cfg.MODEL.ROI_BOX_HEAD.GIOU_WEIGHT = 2.0 cfg.MODEL.ROI_BOX_HEAD.RANDOM_SAMPLE_SIZE = False cfg.MODEL.ROI_BOX_HEAD.RANDOM_SAMPLE_SIZE_UPPER_BOUND = 1.0 cfg.MODEL.ROI_BOX_HEAD.RANDOM_SAMPLE_SIZE_LOWER_BOUND = 0.8 cfg.MODEL.ROI_BOX_HEAD.RANDOM_PROPOSAL_DROP = False cfg.MODEL.ROI_BOX_HEAD.RANDOM_PROPOSAL_DROP_UPPER_BOUND = 1.0 cfg.MODEL.ROI_BOX_HEAD.RANDOM_PROPOSAL_DROP_LOWER_BOUND = 0.8 cfg.MODEL.ROI_BOX_HEAD.MAX_PROPOSAL_PER_BATCH = 0 cfg.MODEL.ROI_BOX_HEAD.SEPARATE_OBJ_CLS = False cfg.MODEL.ROI_BOX_HEAD.FINETUNE_ON_SET = False cfg.MODEL.ROI_BOX_HEAD.CLS_HEAD_NO_BG = False cfg.MODEL.ROI_BOX_HEAD.DETR_EVAL_PROTOCOL = False cfg.MODEL.ROI_BOX_HEAD.USE_DETR_LOSS = False cfg.SOLVER.BOTTOM_UP_MULTIPLIER = 1.0 cfg.SOLVER.TRANSFORMER_MULTIPLIER = 1.0 cfg.SOLVER.OPTIMIZER = "SGD"