def __init__(self, config, model=None, display=True, device='cpu', name='TADT', model_from_mat=True): """ args: target_location - [x1,y1,w,h], 1-index for OTB benchmark TODO: model_from_mat """ super(Tadt_Tracker, self).__init__() #---------------trackers parameters initialization-------------------------- self.name = name self.config = config self.display = display self.device = device self.rescale = 1 self.results = [] self.model_from_mat = model_from_mat #-------------model initialization-------------------- if model is None: self.model = build_vgg16(self.config).to(self.device) else: self.model = model.to(self.device) self.model.train() self.siamese_model = SiameseNet().to(self.device) self.toc = 0
return img_list, gt_bboxes if __name__ == "__main__": from defaults import _C as cfg import time import torch assert ( False ), 'please download "imagenet-vgg-verydeep-16.mat" from "http://www.vlfeat.org/matconvnet/models/imagenet-vgg-verydeep-16.mat" and set its path in defaults.py' device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') root_path = join(realpath(dirname(__file__)), 'sequences/') img_list, gt_bboxes = load_sequece(root_path) #------------------demo------------------------------------------------------------------ model = build_vgg16(cfg) tracker = Tadt_Tracker(cfg, model=model, device=device, display=True) tracker.initialize_tadt(img_list[0], gt_bboxes[0]) #if want to visualize the selected feature, uncomment these lines #tracker.visualize_feature( # features = tracker.features, # stage = 'conv4_3', # srch_window_size = (180,180), # subwindow = tracker.subwindow, # feature_weights = tracker.feature_weights, # balance_weights = tracker.balance_weights # ) for i in range(1, len(img_list)): tracker.tracking(img_list[i], i) print('fps: ', tracker.cal_fps(i))