def __init__(self, tracker_name='stark_s', para_name='baseline', refine_model_name='ARcm_coco_seg', threshold=0.15): self.THRES = threshold '''create tracker''' '''STARK''' tracker_info = Tracker(tracker_name, para_name, "vot20", None) params = tracker_info.get_parameters() params.visualization = False params.debug = False params.visdom_info = { 'use_visdom': False, 'server': '127.0.0.1', 'port': 8097 } self.stark = tracker_info.create_tracker(params) '''Alpha-Refine''' project_path = os.path.join(os.path.dirname(__file__), '..', '..') refine_root = os.path.join(project_path, 'ltr/checkpoints/ltr/ARcm_seg/') refine_path = os.path.join(refine_root, refine_model_name) '''2020.4.25 input size: 384x384''' self.alpha = ARcm_seg(refine_path, input_sz=384)
def __init__(self, tracker_name='stark_st', para_name='baseline'): # create tracker tracker_info = Tracker(tracker_name, para_name, "vot20", None) params = tracker_info.get_parameters() params.visualization = False params.debug = False self.tracker = tracker_info.create_tracker(params)
def run_sequence(seq: Sequence, tracker: Tracker, debug=False, num_gpu=8): """Runs a tracker on a sequence.""" '''2021.1.2 Add multiple gpu support''' try: worker_name = multiprocessing.current_process().name worker_id = int(worker_name[worker_name.find('-') + 1:]) - 1 gpu_id = worker_id % num_gpu torch.cuda.set_device(gpu_id) except: pass def _results_exist(): if seq.object_ids is None: if seq.dataset in ['trackingnet', 'got10k']: base_results_path = os.path.join(tracker.results_dir, seq.dataset, seq.name) bbox_file = '{}.txt'.format(base_results_path) else: bbox_file = '{}/{}.txt'.format(tracker.results_dir, seq.name) return os.path.isfile(bbox_file) else: bbox_files = [ '{}/{}_{}.txt'.format(tracker.results_dir, seq.name, obj_id) for obj_id in seq.object_ids ] missing = [not os.path.isfile(f) for f in bbox_files] return sum(missing) == 0 if _results_exist() and not debug: print('FPS: {}'.format(-1)) return print('Tracker: {} {} {} , Sequence: {}'.format(tracker.name, tracker.parameter_name, tracker.run_id, seq.name)) if debug: output = tracker.run_sequence(seq, debug=debug) else: try: output = tracker.run_sequence(seq, debug=debug) except Exception as e: print(e) return sys.stdout.flush() if isinstance(output['time'][0], (dict, OrderedDict)): exec_time = sum([sum(times.values()) for times in output['time']]) num_frames = len(output['time']) else: exec_time = sum(output['time']) num_frames = len(output['time']) print('FPS: {}'.format(num_frames / exec_time)) if not debug: _save_tracker_output(seq, tracker, output)
def __init__(self, tracker_name='stark_st', para_name='baseline'): # create tracker tracker_info = Tracker(tracker_name, para_name, "vot20lt", None) params = tracker_info.get_parameters() params.visualization = False params.debug = False params.visdom_info = { 'use_visdom': False, 'server': '127.0.0.1', 'port': 8097 } self.tracker = tracker_info.create_tracker(params)
def run_video(tracker_name, tracker_param, videofile, optional_box=None, debug=None, save_results=False): """Run the tracker on your webcam. args: tracker_name: Name of tracking method. tracker_param: Name of parameter file. debug: Debug level. """ tracker = Tracker(tracker_name, tracker_param, "video") tracker.run_video(videofilepath=videofile, optional_box=optional_box, debug=debug, save_results=save_results)