def __init__(self, cfg, logger, writer):
        self.cfg, self.logger, self.writer = cfg, logger, writer
        # Define dataloader
        self.tng_dataloader, self.val_dataloader, self.num_classes, self.num_query = get_dataloader(
            cfg)
        # networks
        self.model = build_model(cfg, self.num_classes)
        # loss function
        self.ce_loss = nn.CrossEntropyLoss()
        self.triplet = TripletLoss(cfg.SOLVER.MARGIN)
        # optimizer and scheduler
        self.opt = make_optimizer(self.cfg, self.model)
        self.lr_sched = make_lr_scheduler(self.cfg, self.opt)

        self._construct()
Beispiel #2
0
    def __init__(self, cfg, logger, writer):
        self.cfg, self.logger, self.writer = cfg, logger, writer
        # Define dataloader
        self.tng_dataloader, self.val_dataloader_collection, self.num_classes, self.num_query_len_collection = get_dataloader(cfg)
        if 'InsDis' in list(self.cfg.SOLVER.LOSSTYPE):
            self.tng_dataloader, self.val_dataloader, self.num_classes, self.num_query = get_ins_dataloader(cfg)
        # networks
        self.model = build_model(cfg, self.num_classes, use_mask=False)
        # loss function
        self.ce_loss = nn.CrossEntropyLoss()
        self.triplet = TripletLoss(cfg.SOLVER.MARGIN)
        self.NCEContrast = NCEAverage(128, len(self.tng_dataloader)*cfg.SOLVER.IMS_PER_BATCH, cfg.NCE.K, cfg.NCE.T, cfg.NCE.M)
        self.NCELoss = NCECriterion(len(self.tng_dataloader))
        # optimizer and scheduler
        self.opt = make_optimizer(self.cfg, self.model)
        self.lr_sched = make_lr_scheduler(self.cfg, self.opt)

        self._construct()
Beispiel #3
0
    def __init__(self, cfg, logger, writer):
        self.cfg, self.logger, self.writer = cfg, logger, writer
        # Define dataloader
        self.tng_dataloader, self.val_dataloader, self.num_classes, self.num_query = get_dataloader(cfg)
        # networks
        self.model = build_model(cfg, self.num_classes)
        self.base_type = self.model.base_type
        # loss function

        if cfg.SOLVER.LABEL_SMOOTH:
            self.ce_loss = CrossEntropyLabelSmooth(self.num_classes)
        else:
            self.ce_loss = nn.CrossEntropyLoss()
        self.triplet = TripletLoss(cfg.SOLVER.MARGIN)
        self.aligned_triplet = TripletLossAlignedReID(margin=cfg.SOLVER.MARGIN)
        self.of_penalty = OFPenalty(beta=1e-6, penalty_position=['intermediate'])
        # optimizer and scheduler
        self.opt = make_optimizer(self.cfg, self.model)
        self.lr_sched = make_lr_scheduler(self.cfg, self.opt)

        self._construct()
Beispiel #4
0
    def __init__(self, cfg, logger, writer):
        self.cfg, self.logger, self.writer = cfg, logger, writer
        # Define dataloader
        self.tng_dataloader, self.val_dataloader_collection, self.num_classes, self.num_query_len_collection = get_dataloader_mask(
            cfg)
        # networks
        self.use_part_erasing = False
        self.num_parts = cfg.MODEL.NUM_PARTS
        self.model = build_model_selfgcn(cfg, self.num_classes)
        self.adj = torch.from_numpy(coarse_adj_npy).float()
        # loss function
        self.ce_loss = nn.CrossEntropyLoss()
        self.triplet = TripletLoss(cfg.SOLVER.MARGIN)
        self.mse_loss = nn.MSELoss()
        # optimizer and scheduler
        self.opt = make_optimizer(self.cfg, self.model)
        self.lr_sched = make_lr_scheduler(self.cfg, self.opt)

        self.loss_weight = [1.0, 1.0, 0.5, 0.5, 0.5, 0.5, 0.4]
        self.logger.info(
            f"Loss weights: {self.loss_weight}, use_pe: {self.use_part_erasing}, use_bnfeat: {True}"
        )
        self._construct()