rex_xai.visualisation¶
image generation functions
Functions¶
|
plots an insertion/deletion curve of a responsibility map |
|
plots a 3d grid in matplotlib given an image <path> |
|
Copy colormap and set alpha values |
|
|
|
plots a contour plot |
|
|
|
|
|
plots a 3d surface plot |
|
|
|
Remove the background from the responsibility map if set in the Data object |
|
Plot a 3D voxel plot of the responsibility map using plotly. |
|
|
|
Generate n evenly spaced RGB colours from a matplotlib colourmap. |
|
Creates a composite mask from a list of masks. |
|
Draws the boundaries of the explanations on the image, using the provided colours. |
|
Return original input image as a numpy array, resized to match model size and converted to RGB if necessary. |
|
|
|
|
|
Plot a grid of images |
Module Contents¶
- rex_xai.visualisation.plot_curve(curve, chunk_size, style='insertion', destination=None)¶
plots an insertion/deletion curve of a responsibility map
- rex_xai.visualisation.plot_3d(path, ranking, ogrid, norm=255.0)¶
plots a 3d grid in matplotlib given an image <path> If <path> is greyscale or RGBA, it is converted to RGB for plotting.
- rex_xai.visualisation._transparent_cmap(cmap, N=255)¶
Copy colormap and set alpha values
- rex_xai.visualisation.heatmap_plot(data, resp_map, colour, path=None)¶
- Parameters:
data (rex_xai.input_data.Data)
- rex_xai.visualisation.contour_plot(path, maps, target, levels=30, destination=None)¶
plots a contour plot
- Parameters:
- rex_xai.visualisation.__group_spectral_parts(explanation)¶
- rex_xai.visualisation.spectral_plot(explanation, data, ranking, colour, extra=True, path=None)¶
- Parameters:
data (rex_xai.input_data.Data)
- rex_xai.visualisation.surface_plot(args, resp_map, target, path=None)¶
plots a 3d surface plot
- Parameters:
args (rex_xai.config.CausalArgs)
resp_map (numpy.ndarray)
target (rex_xai.prediction.Prediction)
- rex_xai.visualisation.overlay_grid(img, step_count=10)¶
- rex_xai.visualisation.remove_background(data, resp_map)¶
Remove the background from the responsibility map if set in the Data object
- Parameters:
data (rex_xai.input_data.Data)
resp_map (numpy.ndarray)
- Return type:
numpy.ndarray
- rex_xai.visualisation.voxel_plot(args, resp_map, data, path=None)¶
Plot a 3D voxel plot of the responsibility map using plotly. - Assumes the data is greyscale Produces an interactive 3D plot of the data and the responsibility map.
- Parameters:
args (rex_xai.config.CausalArgs)
resp_map (torch.Tensor)
data (rex_xai.input_data.Data)
- rex_xai.visualisation.__transpose_mask(explanation, mode, transposed)¶
- rex_xai.visualisation.generate_colours(n, colourmap)¶
Generate n evenly spaced RGB colours from a matplotlib colourmap.
- rex_xai.visualisation.make_composite_mask(explanations)¶
Creates a composite mask from a list of masks.
- rex_xai.visualisation.apply_boundaries_to_image(image, explanations, colours)¶
Draws the boundaries of the explanations on the image, using the provided colours.
- rex_xai.visualisation.get_img_as_array(data)¶
Return original input image as a numpy array, resized to match model size and converted to RGB if necessary.
- rex_xai.visualisation.save_multi_explanation(explanations, data, args, clause=None, path=None)¶
- Parameters:
args (rex_xai.config.CausalArgs)
- rex_xai.visualisation.save_image(explanation, data, args, path=None)¶
- Parameters:
data (rex_xai.input_data.Data)
args (rex_xai.config.CausalArgs)
- rex_xai.visualisation.plot_image_grid(images, ncols=None)¶
Plot a grid of images