def test_vlad_distances_order(): im = 'im1' other_ims = ['im2', 'im3'] histograms = { 'im1': np.array([1, 0, 0]), 'im2': np.array([0, 1, 0]), 'im3': np.array([1, 1, 0]) / np.linalg.norm([1, 1, 0]), } im_res, order_res, other_res = vlad.vlad_distances( im, other_ims, histograms) assert im_res == im assert len(order_res) == len(other_ims) assert other_res == other_ims assert other_ims[order_res[0]] == 'im3' assert other_ims[order_res[1]] == 'im2'
def test_vlad_distances_order(): im = "im1" other_ims = ["im2", "im3"] histograms = { "im1": np.array([1, 0, 0]), "im2": np.array([0, 1, 0]), "im3": np.array([1, 1, 0]) / np.linalg.norm([1, 1, 0]), } im_res, distance_res, other_res = vlad.vlad_distances( im, other_ims, histograms) assert im_res == im assert len(distance_res) == len(other_ims) assert other_res == other_ims order_res = np.argsort(distance_res) assert other_ims[order_res[0]] == "im3" assert other_ims[order_res[1]] == "im2"
def match_vlad_unwrap_args(args): """ Wrapper for parralel processing of VLAD """ image, other_images, histograms = args return vlad.vlad_distances(image, other_images, histograms)
def match_vlad_unwrap_args( args: Tuple[str, Iterable[str], Dict[str, np.ndarray]] ) -> Tuple[str, List[float], List[str]]: """Wrapper for parralel processing of VLAD""" image, other_images, histograms = args return vlad.vlad_distances(image, other_images, histograms)