kolena.workflow.visualization
#
Colormap(fade_low_activation=True)
#
Bases: ABC
A Colormap
maps a pixel intensity to RGBA.
fade_low_activation: bool = fade_low_activation
instance-attribute
#
Fades out the regions with low activation by applying zero alpha value if set
True
; otherwise, activation map is shown as is without any fading applied. By default, it's set to True
.
This option makes the overlay visualization better by highlighting only the important regions.
red(intensity)
abstractmethod
#
Maps a grayscale pixel intensity to color red: [0, 255]
green(intensity)
abstractmethod
#
Maps a grayscale pixel intensity to color green: [0, 255]
blue(intensity)
abstractmethod
#
Maps a grayscale pixel intensity to color blue: [0, 255]
alpha(intensity)
#
Maps the grayscale pixel intensity to alpha: [0, 255]. If fade_low_activation
is False, then it returns the maximum alpha value.
ColormapJet(fade_low_activation=True)
#
Bases: Colormap
The MATLAB "Jet" color palette is a standard palette used for scientific and mathematical data.
It is defined as a linear ramp between the following colours: "#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"
colorize_activation_map(activation_map, colormap=ColormapJet())
#
Applies the specified colormap to the activation map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activation_map
|
ndarray
|
A 2D numpy array, shaped (h, w) or (h, w, 1), of the activation map in |
required |
colormap
|
Colormap
|
The colormap used to colorize the input activation map. Defaults to the MATLAB "Jet" colormap. |
ColormapJet()
|
Returns:
Type | Description |
---|---|
ndarray
|
The colorized activation map in RGBA format, in (h, w, 4) shape. |
encode_png(image, mode)
#
Encodes an image into an in-memory PNG file that is represented as binary data. It is used when you want to upload a 2 or 3-dimensional image in a NumPy array format to cloud.
It can be used in conjunction with
colorized_activation_map
when uploading an
activation map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
ndarray
|
A 2D or 3D NumPy array, shaped either |
required |
mode
|
str
|
A PIL mode |
required |
Returns:
Type | Description |
---|---|
BytesIO
|
The in-memory PNG file represented as binary data. |