Skip to main content

A collection of metrics for comparing saliency maps

Project description

Saliency Metrics

Tests License: MIT PyPI version Documentation Status

Saliency Metrics is a Python package that implements various metrics for comparing saliency maps generated by explanation methods. To ensure fair comparisons, metrics should be computed on the same saliency map and corresponding ground truth map. The package includes the following metrics:

  • SSIM (Structural Similarity Index): A perceptual metric that quantifies the similarity between two images. It considers changes in structural information, luminance, and contrast.
  • PSNR (Peak Signal-to-Noise Ratio): A metric that measures the ratio between the maximum possible power of a signal and the power of corrupting noise. It is often used to assess the quality of reconstructed images.
  • EMD (Earth Mover's Distance): A metric that measures the distance between two probability distributions over a region D. It is often used in computer vision and image retrieval tasks.

tutorial.ipynb is an original way used to check and test the different metrics.

Installation

pip install saliencytools

This module is a work in progress and is not yet complete.

Usage

from saliencytools import ssim, psnr, emd

import numpy as np
import matplotlib.pyplot as plt



# create a random saliency map
saliency_map = np.random.rand(28*28).reshape(28, 28)
# create a random ground truth map
ground_truth_map = np.random.rand(28*28).reshape(28, 28)
# create a random binary mask

# use all the metrics to compare the saliency map with the ground truth map
for metric in [ssim, psnr, emd]:
    
    print(f"{metric.__name__}: {metric(saliency_map, ground_truth_map)}")
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saliencytools-0.30.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saliencytools-0.30-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file saliencytools-0.30.tar.gz.

File metadata

  • Download URL: saliencytools-0.30.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for saliencytools-0.30.tar.gz
Algorithm Hash digest
SHA256 6d558f662de657defbbc34ac43677fc97d9a0fa7972aad4e76365d073377d05e
MD5 09f80b51c1383dac905b3775a4fa2f5d
BLAKE2b-256 c72ee8d32afcf4c2f59f83b0c598fa1d6252bdcd3792ff6d6787205f75971d71

See more details on using hashes here.

File details

Details for the file saliencytools-0.30-py3-none-any.whl.

File metadata

  • Download URL: saliencytools-0.30-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for saliencytools-0.30-py3-none-any.whl
Algorithm Hash digest
SHA256 7790b4cc10e468bd4cddc6e9a9c446ba5ade2e07adc5b55b0d9ceb6e7e795617
MD5 b8e18c6c8ab352fcf5561fffc34a235e
BLAKE2b-256 09b11b13ae00aa0fdf49ad556e626b37d58d5d63b481a07d931b9ea8b7fba00b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page