Exemplo n.º 1
0
def run_trackers(trackers, seqs, evalType):
    tmpRes_path = RESULT_SRC.format('tmp/{0}/'.format(evalType))
    if not os.path.exists(tmpRes_path):
        os.makedirs(tmpRes_path)

    numSeq = len(seqs)

    trackerResults = dict((t, list()) for t in trackers)
    ##################################################
    # chose sequence to run from below
    ##################################################
    # we also collect data fro training here
    import h5py
    f = h5py.File("./data/OTB100_sigma_%d.hdf5",
                  "w",
                  driver="family",
                  memb_size=2**32 - 1)
    X_train = f.create_dataset("x_train", (80000, 5, 240, 160),
                               dtype='float32',
                               chunks=True)
    y_train = f.create_dataset("y_train", (80000, 4),
                               dtype='float32',
                               chunks=True)
    count = 0
    for idxSeq in range(0, numSeq):
        s = seqs[idxSeq]
        subSeqs, subAnno = butil.get_sub_seqs(s, 20.0, evalType)

        for idxTrk in range(len(trackers)):
            t = trackers[idxTrk]

            if not OVERWRITE_RESULT:
                trk_src = os.path.join(RESULT_SRC.format(evalType), t.name)
                result_src = os.path.join(trk_src, s.name + '.json')
                if os.path.exists(result_src):
                    seqResults = butil.load_seq_result(evalType, t, s.name)
                    trackerResults[t].append(seqResults)
                    continue

            seqLen = len(subSeqs)
            for idx in range(seqLen):
                subS = subSeqs[idx]
                subS.name = s.name + '_' + str(idx)
                ####################
                X_train, y_train, count = run_KCF_variant(
                    t, subS, X_train, y_train, count)
                ####################
                print("count %d" % count)
                ####################

    X_train.resize(count - 1, axis=0)
    y_train.resize(count - 1, axis=0)
    f.close()
    print("done")
    # count 58940
    return trackerResults
Exemplo n.º 2
0
def run_trackers(trackers, seqs, evalType):
    tmpRes_path = RESULT_SRC.format('tmp/{0}/'.format(evalType))
    if not os.path.exists(tmpRes_path):
        os.makedirs(tmpRes_path)

    numSeq = len(seqs)

    trackerResults = dict((t, list()) for t in trackers)
    ##################################################
    # chose sequence to run from below
    ##################################################
    for idxSeq in range(24, numSeq):
        s = seqs[idxSeq]
        subSeqs, subAnno = butil.get_sub_seqs(s, 20.0, evalType)

        for idxTrk in range(len(trackers)):
            t = trackers[idxTrk]

            if not OVERWRITE_RESULT:

                trk_src = os.path.join(RESULT_SRC.format(evalType), t.name)
                result_src = os.path.join(trk_src, s.name + '.json')
                if os.path.exists(result_src):
                    seqResults = butil.load_seq_result(evalType, t, s.name)
                    trackerResults[t].append(seqResults)
                    continue
            seqResults = []
            seqLen = len(subSeqs)
            for idx in range(seqLen):
                print('{0}_{1}, {2}_{3}:{4}/{5} - {6}'.format(
                    idxTrk + 1, t.name, idxSeq + 1, s.name, idx + 1, seqLen,
                    evalType))
                subS = subSeqs[idx]
                subS.name = s.name + '_' + str(idx)
                ####################
                t, res = run_KCF_variant(t, subS)
                ####################
                r = Result(t.name, s.name, subS.startFrame, subS.endFrame,
                           res['type'], evalType, res['res'], res['fps'], None)
                try:
                    r.tmplsize = res['tmplsize'][0]
                except:
                    pass
                r.refresh_dict()
                seqResults.append(r)
            # end for subseqs
            if SAVE_RESULT:
                butil.save_seq_result(seqResults)

            trackerResults[t].append(seqResults)
            # end for tracker
    # end for allseqs
    return trackerResults
def run_trackers(trackers, seqs, evalType):
    tmpRes_path = RESULT_SRC.format('tmp/{0}/'.format(evalType))
    if not os.path.exists(tmpRes_path):
        os.makedirs(tmpRes_path)

    numSeq = len(seqs)
    trackerResults = dict((t, list()) for t in trackers)
    ##################################################
    # chose sequence to run from below
    ##################################################
    for idxSeq in range(12, numSeq):
        s = seqs[idxSeq]
        subSeqs, subAnno = butil.get_sub_seqs(s, 20.0, evalType)

        for idxTrk in range(len(trackers)):
            t = trackers[idxTrk]

            if not OVERWRITE_RESULT:

                trk_src = os.path.join(RESULT_SRC.format(evalType), t.name)
                result_src = os.path.join(trk_src, s.name + '.json')
                if os.path.exists(result_src):
                    seqResults = butil.load_seq_result(evalType, t, s.name)
                    trackerResults[t].append(seqResults)
                    continue
            seqLen = len(subSeqs)
            for idx in range(seqLen):
                subS = subSeqs[idx]
                subS.name = s.name + '_' + str(idx)

                ####################
                r_temp = Result(t.name, s.name, subS.startFrame, subS.endFrame,
                                [], evalType, [], [], None)
                t, res = run_KCF_variant(t, subS, r_temp)
                return 0
                ####################
            # end for tracker
    # end for allseqs
    return trackerResults
Exemplo n.º 4
0
def run_trackers(seqs, evalType, shiftTypeSet, tracker_config):
    t = tracker_config['track_name']
    tmpRes_path = RESULT_SRC.format('tmp/{0}/'.format(evalType))
    if not os.path.exists(tmpRes_path):
        os.makedirs(tmpRes_path)

    sess, tracker = build_tracker(tracker_config)

    numSeq = len(seqs)
    trackerResult = []
    for idxSeq in range(numSeq):
        s = seqs[idxSeq]
        subSeqs, subAnno = butil.get_sub_seqs(s, 20.0, evalType)
        if not OVERWRITE_RESULT:
            trk_src = os.path.join(RESULT_SRC.format(evalType), t)
            result_src = os.path.join(trk_src, s.name + '.json')
            if os.path.exists(result_src):
                seqResults = butil.load_seq_result(evalType, t, s.name)
                trackerResult.append(seqResults)
                continue

        seqResults = []
        seqLen = len(subSeqs)
        for idx in range(seqLen):
            rp = tmpRes_path + '_' + t + '_' + str(idx + 1) + '/'
            if SAVE_IMAGE and not os.path.exists(rp):
                os.makedirs(rp)
            subS = subSeqs[idx]
            subS.name = s.name + '_' + str(idx)
            if not tf.gfile.IsDirectory(TRACKER_SRC + t):
                logging.info('Creating training directory: %s',
                             TRACKER_SRC + t)
                tf.gfile.MakeDirs(TRACKER_SRC + t)
            os.chdir(TRACKER_SRC + t)
            try:
                logging.info('Processing {}...'.format(subS.name))
                res = run_SFC(subS, rp, SAVE_IMAGE, sess, tracker)
            except:
                print('failed to execute {0} : {1}'.format(t, sys.exc_info()))
                os.chdir(WORKDIR)
                break
            os.chdir(WORKDIR)

            if evalType == 'SRE':
                r = Result(t, s.name, subS.startFrame, subS.endFrame,
                           res['type'], evalType, res['res'], res['fps'],
                           shiftTypeSet[idx])
            else:
                r = Result(t, s.name, subS.startFrame, subS.endFrame,
                           res['type'], evalType, res['res'], res['fps'], None)
            try:
                r.tmplsize = butil.d_to_f(res['tmplsize'][0])
            except:
                pass
            r.refresh_dict()
            seqResults.append(r)
        if SAVE_RESULT:
            butil.save_seq_result(seqResults)

        trackerResult.append(seqResults)
    return trackerResult