def getImgPathsAndRanksSorted(rows, db_path, class_id, diff, delta, trainFlag, layer): rows_same_class = getImgInfoSameClass(db_path, class_id, trainFlag, layer) indices, img_paths = zip(*rows_same_class) assert list(indices) == sorted(indices) img_paths_all = [] nn_ranks_all = [] for row_curr in rows: img_path_curr, neighbor_index, azimuth_differences = row_curr idx_to_del = img_paths.index(img_path_curr) azimuth_differences[idx_to_del] = -1 * float('Inf') idx_of_interest = getIndexWithAngleDifference(azimuth_differences, diff, delta) indices = np.array(indices) nn_rank, idx_to_order = experiments_super.sortBySmallestDistanceRank( indices[idx_of_interest], neighbor_index) img_paths_sorted = np.array(img_paths)[idx_of_interest][idx_to_order] img_paths_all.append(list(img_paths_sorted)) nn_ranks_all.append(list(nn_rank)) return img_paths_all, nn_ranks_all
def getImgPathsAndRanksSorted(rows, db_path, class_id, trainFlag, layer, pascalFlag): rows_same_class = getImgInfoSameClass(db_path, class_id, trainFlag, layer, pascalFlag) indices, img_paths = zip(*rows_same_class) assert list(indices) == sorted(indices) img_paths_all = [] nn_ranks_all = [] for row_curr in rows: img_path_curr, neighbor_index = row_curr idx_to_del = img_paths.index(img_path_curr) indices_copy = np.delete(indices, [idx_to_del]) nn_rank, idx_to_order = experiments_super.sortBySmallestDistanceRank(indices_copy, neighbor_index) img_paths_sorted = np.array(img_paths)[idx_to_order] img_paths_all.append(list(img_paths_sorted)) nn_ranks_all.append(list(nn_rank)) return img_paths_all, nn_ranks_all
def getImgPathsAndRanksSorted(rows,db_path,class_id,diff,delta,trainFlag,layer): rows_same_class=getImgInfoSameClass(db_path,class_id,trainFlag,layer) indices,img_paths=zip(*rows_same_class); assert list(indices)==sorted(indices) img_paths_all=[]; nn_ranks_all=[]; for row_curr in rows: img_path_curr,neighbor_index,azimuth_differences=row_curr; idx_to_del=img_paths.index(img_path_curr); azimuth_differences[idx_to_del]=-1*float('Inf'); idx_of_interest=getIndexWithAngleDifference(azimuth_differences,diff,delta) indices=np.array(indices); nn_rank,idx_to_order=experiments_super.sortBySmallestDistanceRank(indices[idx_of_interest],neighbor_index); img_paths_sorted=np.array(img_paths)[idx_of_interest][idx_to_order]; img_paths_all.append(list(img_paths_sorted)); nn_ranks_all.append(list(nn_rank)); return img_paths_all,nn_ranks_all