Пример #1
0
    def __init__(self, cfg):
        TwoStage.__init__(self, cfg)

        # specify the training losses you want to print out.
        # The program will call base_model.get_current_losses
        # if cfg.display:
        #     self.visual_names.append('vis_inp')

        # specify the models you want to save to the disk.
        # The program will call base_model.save_networks and base_model.load_networks
        self.model_names = ['detector']

        # detector
        common_kwargs = self.get_common_args(cfg)
        self.detector = BSL(
            num_classes=2,
            # re-ID
            num_train_pids=cfg.num_train_ids,
            cls_type=cfg.cls_type,
            in_level=cfg.in_level,
            **common_kwargs)

        # shift network to device
        self.net_to_device()
        if not cfg.is_test: self.init_optim(cfg)
Пример #2
0
    def modify_commandline_options(parser, is_test):
        # common arguments
        parser = TwoStage.modify_commandline_options(parser, is_test)
        # specific arguments
        parser.add_argument('--alpha', type=float, default=0.01, help='warm-up lower lr factor')
        parser.add_argument('--cat_c4', action='store_true', help="concat cov4 and cov5 features as re-ID feature")
        parser.add_argument('--cls_type', type=str, default='oim', help='type of classifier')
        parser.add_argument('--reid_lr', type=float, default=3.5e-4, help='lr of re-ID parameters')
        parser.add_argument('--det_thr', type=float, default=0.01)
        parser.add_argument('--uni_optim', action='store_true', help="Differs optimizers for detection and re-ID.")
        parser.add_argument('--use_mask', action='store_true', help="enable segmentation head")

        cfg = parser.parse_args()
        parser.set_defaults(num_train_ids=5532 if cfg.benchmark == "ssm" else 483)

        # initialize experiment name
        model_name = cfg.backbone
        model_name += 'cat' if cfg.cat_c4 else ""
        model_name += "fs" if cfg.use_mask else ""  # foreground segmentation
        model_name += cfg.cls_type
        augment = "b{}".format(cfg.batch_size)
        augment += "uo" if cfg.uni_optim else "do"
        augment += "wu" if cfg.warmup_epochs > 0 else ""
        augment += "cg" if cfg.clip_grad else ""
        augment += "ba" if cfg.bg_aug else ""

        if not is_test:
            parser.set_defaults(expr_name="{}*{}*{}".format(cfg.benchmark, model_name, augment))

        return parser