VisionHeatmaps.jl

Documentation for VisionHeatmaps.jl.

Installation

To install this package and its dependencies, open the Julia REPL and run

]add VisionHeatmaps

API

VisionHeatmaps.heatmapFunction
heatmap(x::AbstractArray)

Visualize 4D arrays as heatmaps, assuming the WHCN convention for input array dimensions (width, height, color channels, batch dimension).

Keyword arguments

  • colorscheme::Union{ColorScheme,Symbol}: Color scheme from ColorSchemes.jl. Defaults to seismic.
  • reduce::Symbol: Selects how color channels are reduced to a single number to apply a color scheme. The following methods can be selected, which are then applied over the color channels for each "pixel" in the array:
    • :sum: sum up color channels
    • :norm: compute 2-norm over the color channels
    • :maxabs: compute maximum(abs, x) over the color channels
    • :sumabs: compute sum(abs, x) over the color channels
    • :abssum: compute abs(sum(x)) over the color channels
    Defaults to :sum.
  • rangescale::Symbol: Selects how the color channel reduced heatmap is normalized before the color scheme is applied. Can be either :extrema or :centered. Defaults to :centered.
  • permute::Bool: Whether to flip W&H input channels. Default is true.
  • process_batch::Bool: When heatmapping a batch, setting process_batch=true will apply the rangescale normalization to the entire batch instead of computing it individually for each sample in the batch. Defaults to false.
  • unpack_singleton::Bool: If false, heatmap will always return a vector of images. When heatmapping a batch with a single sample, setting unpack_singleton=true will unpack the singleton vector and directly return the image. Defaults to true.
source
heatmap(expl::Explanation)

Visualize Explanation from XAIBase as a vision heatmap. Assumes WHCN convention (width, height, channels, batch dimension) for explanation.val.

This will use the default heatmapping style for the given type of explanation. Defaults can be overridden via keyword arguments.

source
heatmap(input::AbstractArray, analyzer::AbstractXAIMethod)

Compute an Explanation for a given input using the XAI method analyzer and visualize it as a vision heatmap.

Any additional arguments and keyword arguments are passed to the analyzer. Refer to the analyze documentation for more information on available keyword arguments.

To customize the heatmapping style, first compute an explanation using analyze and then call heatmap on the explanation.

source
VisionHeatmaps.heatmap_overlayFunction
heatmap_overlay(val, image)

Create a heatmap from val and overlay it on top of an image. Assumes 4D input array following the WHCN convention (width, height, color channels, batch dimension) and batch size 1.

Keyword arguments

  • alpha: Opacity of the heatmap overlay. Defaults to 0.6. If an array is passed, it will be broadcast with the image and heatmap. All alpha values are expected to be between 0 and 1.
  • resize_method: Method used to resize the heatmap in case of a size mismatch with the image. Defaults to Lanczos(1) from Interpolations.jl.

Further keyword arguments are passed to heatmap. Refer to the heatmap documentation for more information.

source
heatmap_overlay(expl::Explanation, image)

Visualize Explanation from XAIBase as a vision heatmap and overlay it on top of an image. Assumes WHCN convention (width, height, channels, batch dimension) for explanation.val and batch size 1.

This will use the default heatmapping style for the given type of explanation. Refer to the heatmap and heatmap_overlay documentation for a list of supported keyword arguments that can be used to override the defaults.

source