model_images = [x.strip() for x in model_images] with open('query.txt') as fp: query_images = fp.readlines() query_images = [x.strip() for x in query_images] dist_type = 'intersect' hist_type = 'rg' num_bins = 30 [best_match, D] = match_module.find_best_match(model_images, query_images, dist_type, hist_type, num_bins) ## visualize nearest neighbors (Question 3.b) query_images_vis = [query_images[i] for i in np.array([0, 4, 9])] match_module.show_neighbors(model_images, query_images_vis, dist_type, hist_type, num_bins) ## compute recognition percentage (Question 3.c) # import ipdb; ipdb.set_trace() num_correct = sum(best_match == range(len(query_images))) print('number of correct matches: %d (%f)\n' % (num_correct, 1.0 * num_correct / len(query_images))) # %% # All combinations def grid_search(model_images, query_images, dist_type, hist_type, num_bins): [best_match,
#l2 eval_dist_type = 'intersect' #grayvalue #rgb #rg #dxdy eval_hist_type = 'rgb' eval_num_bins = 60 [best_match, D] = match_module.find_best_match(model_images, query_images, eval_dist_type, eval_hist_type, eval_num_bins) ## visualize nearest neighbors (Question 3.b) query_images_vis = [query_images[i] for i in np.array([0, 4, 9])] match_module.show_neighbors(model_images, query_images_vis, eval_dist_type, eval_hist_type, eval_num_bins) ## compute recognition percentage (Question 3.c) # import ipdb; ipdb.set_trace() num_correct = sum(best_match == range(len(query_images))) print('number of correct matches: %d (%f)\n' % (num_correct, 1.0 * num_correct / len(query_images))) # plot recall_precision curves (Question 4) with open('model.txt') as fp: model_images = fp.readlines() model_images = [x.strip() for x in model_images] with open('query.txt') as fp: query_images = fp.readlines()