VisionHeatmaps.jl
Documentation for VisionHeatmaps.jl.
Installation
To install this package and its dependencies, open the Julia REPL and run
]add VisionHeatmaps
API
VisionHeatmaps.heatmap
— Functionheatmap(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 toseismic
.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
: computemaximum(abs, x)
over the color channels:sumabs
: computesum(abs, x)
over the color channels:abssum
: computeabs(sum(x))
over the color channels
: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 istrue
.process_batch::Bool
: When heatmapping a batch, settingprocess_batch=true
will apply therangescale
normalization to the entire batch instead of computing it individually for each sample in the batch. Defaults tofalse
.unpack_singleton::Bool
: If false,heatmap
will always return a vector of images. When heatmapping a batch with a single sample, settingunpack_singleton=true
will unpack the singleton vector and directly return the image. Defaults totrue
.
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.
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.
VisionHeatmaps.heatmap_overlay
— Functionheatmap_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 to0.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 toLanczos(1)
from Interpolations.jl.
Further keyword arguments are passed to heatmap
. Refer to the heatmap
documentation for more information.
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.