diff options
Diffstat (limited to 'evaluate.py')
-rwxr-xr-x | evaluate.py | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/evaluate.py b/evaluate.py index 54a6a9d..0ff2783 100755 --- a/evaluate.py +++ b/evaluate.py @@ -38,23 +38,22 @@ from logging import debug parser = argparse.ArgumentParser() parser.add_argument("-t", "--train", help="Use test data instead of query", action='store_true') parser.add_argument("-c", "--conf_mat", help="Show visual confusion matrix", action='store_true') -parser.add_argument("-k", "--kmean", help="Perform Kmeans", action='store_true', default=0) +parser.add_argument("-k", "--kmean_alt", help="Perform clustering with generalized labels(not actual kmean)", action='store_true', default=0) parser.add_argument("-m", "--mahalanobis", help="Perform Mahalanobis Distance metric", action='store_true', default=0) -parser.add_argument("-e", "--euclidean", help="Standard euclidean", action='store_true', default=0) +parser.add_argument("-e", "--euclidean", help="Use standard euclidean distance", action='store_true', default=0) parser.add_argument("-r", "--rerank", help="Use k-reciprocal rernaking", action='store_true') -parser.add_argument("-p", "--reranka", help="Parameter 1 for Rerank", type=int, default = 9) -parser.add_argument("-q", "--rerankb", help="Parameter 2 for rerank", type=int, default = 3) -parser.add_argument("-l", "--rerankl", help="Coefficient to combine distances", type=float, default = 0.3) -parser.add_argument("-n", "--neighbors", help="Number of neighbors", type=int, default = 1) +parser.add_argument("-p", "--reranka", help="Parameter k1 for Rerank -p '$k1val' -ARGUMENT REQUIRED, default=9-", type=int, default = 9) +parser.add_argument("-q", "--rerankb", help="Parameter k2 for rerank -q '$k2val' -ARGUMENT REQUIRED, default=3-", type=int, default = 3) +parser.add_argument("-l", "--rerankl", help="Coefficient to combine distances(lambda) -l '$lambdaval' -ARGUMENT REQUIRED, default=0.3-", type=float, default = 0.3) +parser.add_argument("-n", "--neighbors", help="Use customized ranklist size -n 'size' -ARGUMENT REQUIRED, default=1-", type=int, default = 1) parser.add_argument("-v", "--verbose", help="Use verbose output", action='store_true') -parser.add_argument("-s", "--showrank", help="Save ranklist pic id in a txt file", type=int, default = 0) -parser.add_argument("-1", "--normalise", help="Normalized features", action='store_true', default=0) -parser.add_argument("-M", "--multrank", help="Run for different ranklist sizes equal to M", type=int, default=1) -parser.add_argument("-C", "--comparison", help="Set to 2 to obtain a comparison of baseline and Improved metric", type=int, default=1) -parser.add_argument("--data", help="Data folder with features data", default='data') -parser.add_argument("-V", "--validation", help="Validation Mode", action='store_true') -parser.add_argument("-K", "--kmean_alt", help="Kmean", type=int, default=0) -parser.add_argument("-P", "--mAP", help="Mean Average Precision", action='store_true') +parser.add_argument("-s", "--showrank", help="Save ranklist pics id in a txt file. Number of ranklists saved specified as -s '$number' -ARGUMENT REQUIRED, default=0-", type=int, default = 0) +parser.add_argument("-1", "--normalise", help="Normalise features", action='store_true', default=0) +parser.add_argument("-M", "--multrank", help="Run for different ranklist sizes equal to M -ARGUMENT REQUIRED, default=1-", type=int, default=1) +parser.add_argument("-C", "--comparison", help="Set to 2 to obtain a comparison of baseline and improved metric -ARGUMENT REQUIRED, default=1-", type=int, default=1) +parser.add_argument("--data", help="You can either put the data in a folder called 'data', or specify the location with --data 'path' -ARGUMENT REQUIRED, default='data'-", default='data') +parser.add_argument("-K", "--kmean", help="Perform Kmean clustering of size specified through -K '$size' -ARGUMENT REQUIRED, default=0-", type=int, default=0) +parser.add_argument("-P", "--mAP", help="Display Mean Average Precision for ranklist of size -n '$size'", action='store_true') args = parser.parse_args() @@ -196,12 +195,8 @@ def main(): del test del tt else: - if args.validation: - query_idx = train_idx.reshape(train_idx.shape[0]) - gallery_idx = train_idx.reshape(train_idx.shape[0]) - else: - query_idx = query_idx.reshape(query_idx.shape[0]) - gallery_idx = gallery_idx.reshape(gallery_idx.shape[0]) + query_idx = query_idx.reshape(query_idx.shape[0]) + gallery_idx = gallery_idx.reshape(gallery_idx.shape[0]) camId = camId.reshape(camId.shape[0]) showfiles_train = filelist[gallery_idx] @@ -220,12 +215,12 @@ def main(): debug("Normalising data") train_data = np.divide(train_data,LA.norm(train_data,axis=0)) test_data = np.divide(test_data, LA.norm(test_data,axis=0)) - if(args.kmean): + if(args.kmean_alt): debug("Using Kmeans") train_data, train_label, train_cam = create_kmean_clusters(feature_vectors, labels,gallery_idx,camId) - if args.kmean_alt: - kmeans = KMeans(n_clusters=args.kmean_alt, random_state=0).fit(train_data) + if args.kmean: + kmeans = KMeans(n_clusters=args.kmean, random_state=0).fit(train_data) neigh = NearestNeighbors(n_neighbors=1) neigh.fit(kmeans.cluster_centers_) neighbors = neigh.kneighbors(test_data, return_distance=False) |