SimilarityScoring

class xaitk_saliency.impls.gen_descriptor_sim_sal.similarity_scoring.SimilarityScoring(proximity_metric: str = 'euclidean')

This saliency implementation transforms proximity in feature space into saliency heatmaps. This should require feature vectors for the reference image, for each query image, and for perturbed versions of the reference image, as well as the masks of the reference image perturbations (as would be output from a PerturbImage implementation).

The resulting saliency maps are relative to the reference image. As such, each map denotes regions in the reference image that make it more or less similar to the corresponding query image.

Methods

from_config

Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.

generate

Generate visual saliency heatmaps for similarity from vectors

get_config

Get the configuration dictionary of the SimilarityScoring instance.

get_default_config

Generate and return a default configuration dictionary for this class.

get_impls

Discover and return a set of classes that implement the calling class.

is_usable

Check whether this class is available for use.

__init__(proximity_metric: str = 'euclidean') None

Initialization for SimilarityScoring

Parameters:

proximity_metric

The type of comparison metric used to determine proximity in feature space. The type of comparison metric supported is restricted by scipy’s cdist() function. The following metrics are supported in scipy.

‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘cityblock’, ‘correlation’, ‘cosine’, ‘dice’, ‘euclidean’, ‘hamming’, ‘jaccard’, ‘jensenshannon’, ‘kulsinski’, ‘mahalanobis’, ‘matching’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘wminkowski’, ‘yule’.

generate(ref_descr: ndarray, query_descrs: ndarray, perturbed_descrs: ndarray, perturbed_masks: ndarray) ndarray

Generate visual saliency heatmaps for similarity from vectors

Parameters:
  • ref_descr – np.ndarray Feature vectors from the reference image

  • query_descrs – np.ndarray Query vectors from the reference image

  • perturbed_descrs – np.ndarray Perturbed vectors from the reference image

  • perturbed_masks – np.ndarray Perturbation masks numpy.ndarray over the reference image.

Returns:

np.ndarray Generated visual saliency heatmap.

get_config() dict

Get the configuration dictionary of the SimilarityScoring instance.

Returns:

dict[str, Any]: Configuration dictionary.