Exemplo n.º 1
0
    def __init__(self, params, model_path = None, name='SiamRPN', **kargs):
        super(TrackerSiamRPNLate, self).__init__(name=name, is_deterministic=True)

        self.model = SiameseAlexNetLate()

        self.cuda = torch.cuda.is_available()
        self.device = torch.device('cuda:0' if self.cuda else 'cpu')

        checkpoint = torch.load(model_path, map_location = self.device)
        #print("1")
        if 'model' in checkpoint.keys():
            self.model.load_state_dict(torch.load(model_path, map_location = self.device)['model'])
        else:
            self.model.load_state_dict(torch.load(model_path, map_location = self.device))


        if self.cuda:
            self.model = self.model.cuda()
        self.model.eval()
        self.transforms = transforms.Compose([
            ToTensor()
        ])

        valid_scope = 2 * config.valid_scope + 1
        self.anchors = util.generate_anchors(   config.total_stride,
                                                config.anchor_base_size,
                                                config.anchor_scales,
                                                config.anchor_ratios,
                                                valid_scope)
        self.window = np.tile(np.outer(np.hanning(config.score_size), np.hanning(config.score_size))[None, :],
                              [config.anchor_num, 1, 1]).flatten()

        self.data_loader = TrackerRGBTDataLoader()
        self.old_loader = TrackerDataLoader()
Exemplo n.º 2
0
 def __init__(self,
              data_roots=('/media/nlpr/zwzhou/数据资源/MOT16/train', ),
              subsets=(('MOT16-02', 'MOT16-04', 'MOT16-05', 'MOT16-09',
                        'MOT16-10', 'MOT16-11', 'MOT16-13'), ),
              transform=True):
     self.visible_th = 0.4
     self.img_files, self.labels = [], []
     for i, dr in enumerate(data_roots):
         subset = subsets[i]
         for ss in subset:
             self.img_files.append([
                 osp.join(dr, ss, 'img1', k)
                 for k in os.listdir(osp.join(dr, ss, 'img1'))
             ])
             self.labels.append(
                 self.read_labels(osp.join(dr, ss, 'gt/gt.txt')))
     self.index_split = [len(t) for t in self.img_files]
     self.acc_indices = [
         sum(self.index_split[:i]) for i in range(len(self.index_split))
     ]
     self.transform = transform
     self.anchors = util.generate_anchors(config.stride, config.stride,
                                          config.anchor_scales,
                                          config.anchor_ratios,
                                          config.score_size)
Exemplo n.º 3
0
    def __init__(self, net_path=None, **kargs):
        super(TrackerSiamRPN, self).__init__(name='SiamRPN',
                                             is_deterministic=True)
        '''setup GPU device if available'''
        self.cuda = torch.cuda.is_available()
        self.device = torch.device('cuda:0' if self.cuda else 'cpu')
        '''setup model'''
        self.net = SiameseAlexNet()

        if net_path is not None:
            self.net.load_state_dict(
                torch.load(net_path,
                           map_location=lambda storage, loc: storage))
        if self.cuda:
            self.net = self.net.to(self.device)
        '''setup optimizer'''
        self.optimizer = torch.optim.SGD(self.net.parameters(),
                                         lr=config.lr,
                                         momentum=config.momentum,
                                         weight_decay=config.weight_decay)

        self.anchors = util.generate_anchors(config.anchor_total_stride,
                                             config.anchor_base_size,
                                             config.anchor_scales,
                                             config.anchor_ratios,
                                             config.anchor_valid_scope)
Exemplo n.º 4
0
    def __init__(self, seq_dataset, name='GOT-10k'):

        self.max_inter = config.max_inter
        self.sub_class_dir = seq_dataset
        self.ret = {}
        self.count = 0
        self.name = name
        self.anchors = util.generate_anchors(config.anchor_total_stride,
                                             config.anchor_base_size,
                                             config.anchor_scales,
                                             config.anchor_ratios,
                                             config.score_size)
Exemplo n.º 5
0
    def __init__(self, seq_dataset_rgb, seq_dataset_i, z_transforms, x_transforms, name = 'RGBT-234'):

        self.max_inter     = config.max_inter
        self.z_transforms  = z_transforms
        self.x_transforms  = x_transforms
        self.seq_dataset_rgb = seq_dataset_rgb
        self.seq_dataset_i = seq_dataset_i
        self.ret           = {}
        self.count         = 0
        self.index         = 3000
        self.name          = name
        self.anchors       = util.generate_anchors( config.anchor_total_stride,
                                                    config.anchor_base_size,
                                                    config.anchor_scales,
                                                    config.anchor_ratios,
                                                    config.score_size)