Ejemplo n.º 1
0
def db_eval(techniques,
            sequences,
            inputdir=cfg.PATH.SEGMENTATION_DIR,
            metrics=None):
    """ Perform per-frame sequence evaluation.

	Arguments:
		techniques (string,list): name(s) of the method to be evaluated.
		sequences  (string,list): name(s) of the sequence to be evaluated.
		inputdir  (string): path to the technique(s) folder.

	Returns:
		db_eval_dict[method][measure][sequence] (dict): evaluation results.

	"""

    if isinstance(techniques, str): techniques = [techniques]
    if isinstance(sequences, str): sequences = [sequences]

    ndict = lambda: defaultdict(ndict)
    db_eval_dict = ndict()

    # RAW, per-frame evaluation
    timer = Timer()
    log.info("Number of cores allocated: %d" % cfg.N_JOBS)
    for technique in techniques:
        log.info('Evaluating technique: "%s"' % technique)
        timer.tic()

        J,j_M,j_O,j_D,F,f_M,f_O,f_D,T,t_M = \
           zip(*Parallel(n_jobs=cfg.N_JOBS)(delayed(db_eval_sequence)(
         technique,sequence,inputdir,metrics) for sequence in sequences))
        log.info('Processing time: "%.3f"' % timer.toc())

        # STORE RAW EVALUATION
        for seq_id, sequence in enumerate(sequences):
            db_eval_dict[technique]['J'][sequence] = J[seq_id]
            db_eval_dict[technique]['F'][sequence] = F[seq_id]
            db_eval_dict[technique]['T'][sequence] = T[seq_id]

    return db_eval_dict
Ejemplo n.º 2
0
def db_eval(techniques,sequences,inputdir=cfg.PATH.SEGMENTATION_DIR,metrics=None):

	""" Perform per-frame sequence evaluation.

	Arguments:
		techniques (string,list): name(s) of the method to be evaluated.
		sequences  (string,list): name(s) of the sequence to be evaluated.
		inputdir  (string): path to the technique(s) folder.

	Returns:
		db_eval_dict[method][measure][sequence] (dict): evaluation results.

	"""

	if isinstance(techniques,str): techniques = [techniques]
	if isinstance(sequences,str):  sequences  = [sequences]

	ndict        = lambda: defaultdict(ndict)
	db_eval_dict = ndict()

	# RAW, per-frame evaluation
	timer = Timer()
	log.info("Number of cores allocated: %d"%cfg.N_JOBS)
	for technique in techniques:
		log.info('Evaluating technique: "%s"'%technique)
		timer.tic()

		J,j_M,j_O,j_D,F,f_M,f_O,f_D,T,t_M = \
				 zip(*Parallel(n_jobs=cfg.N_JOBS)(delayed(db_eval_sequence)(
			technique,sequence,inputdir,metrics) for sequence in sequences))
		log.info('Processing time: "%.3f"'%timer.toc())

		# STORE RAW EVALUATION
		for seq_id,sequence in enumerate(sequences):
			db_eval_dict[technique]['J'][sequence] = J[seq_id]
			db_eval_dict[technique]['F'][sequence] = F[seq_id]
			db_eval_dict[technique]['T'][sequence] = T[seq_id]

	return db_eval_dict
Ejemplo n.º 3
0
from davis.dataset import DAVISAnnotationLoader, DAVISSegmentationLoader

if __name__ == '__main__':

    sequence_name = 'flamingo'
    technique_name = 'fcp'

    sourcedir = osp.join(cfg.PATH.SEGMENTATION_DIR, 'fcp', sequence_name)

    db_annotation = DAVISAnnotationLoader(cfg, osp.basename(sourcedir))
    db_segmentation = DAVISSegmentationLoader(cfg, osp.basename(sourcedir),
                                              osp.dirname(sourcedir))

    log.info('Starting evaluation of technique: "%s" on sequence "%s"' %
             (technique_name, sequence_name))

    # Initialize timer
    timer = Timer().tic()

    # Processs sequence
    J, Jm, Jo, Jt = db_annotation.eval(db_segmentation, 'J')

    # Report results
    log.info("Processing time: %.3f seconds" % timer.toc())

    table = ptable(['Sequence'] + ['Jm', 'Jo', 'Jt'])
    table.add_row([sequence_name] +
                  ["{: .3f}".format(f) for f in [Jm, Jo, Jt]])

    print "\n" + str(table)
Ejemplo n.º 4
0
from davis.dataset import DAVISAnnotationLoader,DAVISSegmentationLoader

if __name__ == '__main__':

	sequence_name  = 'flamingo'
	technique_name = 'fcp'

	sourcedir = osp.join(cfg.PATH.SEGMENTATION_DIR,'fcp',sequence_name)

	db_annotation   = DAVISAnnotationLoader(cfg,osp.basename(sourcedir))
	db_segmentation = DAVISSegmentationLoader(
			cfg,osp.basename(sourcedir),osp.dirname(sourcedir))

	log.info('Starting evaluation of technique: "%s" on sequence "%s"'%(
		technique_name,sequence_name))


	# Initialize timer
	timer = Timer().tic()

	# Processs sequence
	J,Jm,Jo,Jt = db_annotation.eval(db_segmentation,'J')

	# Report results
	log.info("Processing time: %.3f seconds"%timer.toc())

	table = ptable(['Sequence']+['Jm','Jo','Jt'])
	table.add_row([sequence_name]+["{: .3f}".format(f) for f in [Jm,Jo,Jt]])

	print "\n" + str(table)