Beispiel #1
0
def main():
    args = parse_args()

    # prepare model (SiamRPN or SiamFC)

    # prepare tracker
    info = edict()
    info.arch = args.arch
    info.dataset = 'VOT2019'
    info.TRT = 'TRT' in args.arch
    info.epoch_test = False

    siam_info = edict()
    siam_info.arch = args.arch
    siam_info.dataset = 'VOT2019'
    siam_info.online = args.online
    siam_info.epoch_test = False
    siam_info.TRT = 'TRT' in args.arch

    siam_info.align = False

    if siam_info.TRT:
        siam_info.align = False

    siam_tracker = DAG(siam_info)
    siam_net = models.__dict__[args.arch](align=siam_info.align, online=args.online)
    print('===> init Siamese <====')

    if not siam_info.TRT:
        siam_net = load_pretrain(siam_net, args.resume)
    else:
        print("tensorrt toy model: not loading checkpoint")
    siam_net.eval()
    siam_net = siam_net.cuda()

    if siam_info.TRT:
        print('===> load model from TRT <===')
        print('===> please ignore the warning information of TRT <===')
        print('===> We only provide a toy demo for TensorRT. There are some operations are not supported well.<===')
        print('===> If you wang to test on benchmark, please us Pytorch version. <===')
        print('===> The tensorrt code will be contingously optimized (with the updating of official TensorRT.)<===')
        trtNet = reloadTRT()
        siam_net.tensorrt_init(trtNet)

    if args.online:
        online_tracker = ONLINE(info)
    else:
        online_tracker = None

    print('[*] ======= Track video with {} ======='.format(args.arch))

    # check init box is list or not
    if not isinstance(args.init_bbox, list) and args.init_bbox is not None:
        args.init_bbox = list(eval(args.init_bbox))
    else:
        args.init_bbox = None
        print('===> please draw a box with your mouse <====')

    track_video(siam_tracker, online_tracker, siam_net, args.video, init_box=args.init_bbox, args=args)
Beispiel #2
0
def main():
    print('Warning: this is a demo to test OceanPlus')
    print(
        'Warning: if you want to test it on VOT2020, please use our integration scripts'
    )
    args = parse_args()

    info = edict()
    info.arch = args.arch
    info.dataset = args.dataset
    info.online = args.online
    info.TRT = 'TRT' in args.arch

    siam_info = edict()
    siam_info.arch = args.arch
    siam_info.dataset = args.dataset
    siam_info.vis = args.vis
    siam_tracker = OceanPlus(siam_info)

    if args.mms == 'True':
        MMS = True
    else:
        MMS = False
    siam_net = models.__dict__[args.arch](online=args.online, mms=MMS)
    print('===> init Siamese <====')
    siam_net = load_pretrain(siam_net, args.resume)
    siam_net.eval()
    siam_net = siam_net.cuda()

    # if info.TRT:
    #     print('===> load model from TRT <===')
    #     print('===> please ignore the warning information of TRT <===')
    #     trtNet = reloadTRT()
    #     siam_net.tensorrt_init(trtNet)

    if args.online:
        online_tracker = ONLINE(info)
    else:
        online_tracker = None

    print('====> warm up <====')
    for i in tqdm(range(20)):
        siam_net.template(
            torch.rand(1, 3, 127, 127).cuda(),
            torch.rand(1, 127, 127).cuda())
        siam_net.track(torch.rand(1, 3, 255, 255).cuda())

    # prepare video
    print('====> load dataset <====')
    dataset = load_dataset(args.dataset)
    video_keys = list(dataset.keys()).copy()

    # hyper-parameters in or not
    if args.hp is None:
        hp = None
    elif isinstance(args.hp, str):
        f = open(join('tune', args.hp), 'r')
        hp = json.load(f)
        f.close()
        print('====> tuning hp: {} <===='.format(hp))
    else:
        raise ValueError('not supported hyper-parameters')

    # tracking all videos in benchmark
    for video in video_keys:
        if args.dataset in ['DAVIS2016', 'DAVIS2017', 'YTBVOS']:  # VOS
            track_vos(siam_tracker, online_tracker, siam_net, dataset[video],
                      args, hp)
        else:  # VOTS (i.e. VOT2020)
            if video == 'butterfly':
                track(siam_tracker, online_tracker, siam_net, dataset[video],
                      args)
Beispiel #3
0
def main():
    args = parse_args()

    info = edict()
    info.arch = args.arch
    info.dataset = args.dataset
    info.TRT = 'TRT' in args.arch
    info.epoch_test = args.epoch_test

    siam_info = edict()
    siam_info.arch = args.arch
    siam_info.dataset = args.dataset
    siam_info.online = args.online
    siam_info.epoch_test = args.epoch_test
    siam_info.TRT = 'TRT' in args.arch
    if args.online:
        siam_info.align = False
    else:
        siam_info.align = True if 'VOT' in args.dataset and args.align == 'True' else False

    if siam_info.TRT:
        siam_info.align = False

    siam_tracker = Ocean(siam_info)
    siam_net = models.__dict__[args.arch](align=siam_info.align,
                                          online=args.online)
    print(siam_net)
    print('===> init Siamese <====')

    if not siam_info.TRT:
        siam_net = load_pretrain(siam_net, args.resume)
    else:
        print("tensorrt toy model: not loading checkpoint")
    siam_net.eval()
    siam_net = siam_net.cuda()

    if siam_info.TRT:
        print('===> load model from TRT <===')
        print('===> please ignore the warning information of TRT <===')
        print(
            '===> We only provide a toy demo for TensorRT. There are some operations are not supported well.<==='
        )
        print(
            '===> If you wang to test on benchmark, please us Pytorch version. <==='
        )
        print(
            '===> The tensorrt code will be contingously optimized (with the updating of official TensorRT.)<==='
        )
        trtNet = reloadTRT()
        siam_net.tensorrt_init(trtNet)

    if args.online:
        online_tracker = ONLINE(info)
    else:
        online_tracker = None

    print('====> warm up <====')
    for i in tqdm(range(10)):
        siam_net.template(torch.rand(1, 3, 127, 127).cuda())
        siam_net.track(torch.rand(1, 3, 255, 255).cuda())

    # prepare video
    dataset = load_dataset(args.dataset)
    video_keys = list(dataset.keys()).copy()

    if args.video is not None:
        track(siam_tracker, online_tracker, siam_net, dataset[args.video],
              args)
    else:
        for video in video_keys:
            track(siam_tracker, online_tracker, siam_net, dataset[video], args)