help='actual descriptors to save then') parser.add_argument('--ds', '--descriptor_suffix', help='suffix for descriptor folder') parser.add_argument('--cluster', required=True, help='points to the cluster file') parser.add_argument('--ratio', type=float, help='max ratio 1st to 2nd nearest cluster') return parser if __name__ == '__main__': parser = argparse.ArgumentParser(description='Clustering - Index') parser = pc.commonArguments(parser) parser = addArguments(parser) args = parser.parse_args() np.random.seed(42) if not os.path.exists(args.outputfolder): pc.mkdir_p(args.outputfolder) print args.max_descriptors files, labels = pc.getFiles(args.inputfolder, args.suffix, args.labelfile, concat=True) print 'n-files:', len(files)
print "NN {:10} TOP-1: {:7} mAP: {:12}".format(name, top1, mAP) return top1, mAP def runNN(descriptors, labels, parallel, nprocs): """ compute nearest neighbor from specific descriptors, given labels """ distance_method = { "cosine": 'cosine' } ret_matrix = None for name, method in distance_method.iteritems(): dist_matrix = computeDistances(descriptors, method, parallel, nprocs) computeStats(name, dist_matrix, labels, parallel) ret_matrix = dist_matrix return ret_matrix if __name__ == '__main__': parser = argparse.ArgumentParser(description="Evaluate stuff") parser = pc.commonArguments(parser) args = parser.parse_args() descr_files, labels = pc.getFiles(args.inputfolder, args.suffix, args.labelfile, exact=True) descriptors = pc.loadDescriptors(descr_files) ret_matrix = runNN( descriptors, labels, args.parallel )