signxai.utils package

Submodules

signxai.utils.utils module

Framework-agnostic utility functions for SignXAI2.

This module contains utility functions that work independently of any deep learning framework. Framework-specific utilities have been moved to: - signxai/tf_signxai/tf_utils.py for TensorFlow utilities - signxai/torch_signxai/torch_utils.py for PyTorch utilities

signxai.utils.utils.get_examples_data_dir()[source]

Get the path to the examples/data directory regardless of current working directory

Returns:

Path to the examples/data directory

Return type:

str

signxai.utils.utils.aggregate_and_normalize_relevancemap_rgb(relevancemap)[source]

Aggregate and normalize a RGB relevance map

Parameters:

relevancemap – RGB relevance map

Returns:

Normalized relevance map

signxai.utils.utils.normalize_heatmap(heatmap)[source]

Normalize a heatmap to the range [-1, 1]

Parameters:

heatmap – Heatmap to normalize

Returns:

Normalized heatmap

signxai.utils.utils.remove_softmax(model)[source]

Remove the softmax activation from the last layer of a model.

This function delegates to the appropriate framework-specific implementation.

Parameters:

model – TensorFlow or PyTorch model

Returns:

Model with softmax removed

signxai.utils.utils.calculate_explanation_innvestigate(model, x, method='lrp.epsilon', neuron_selection=None, batchmode=False, **kwargs)[source]

Calculate an explanation using the innvestigate backend (TensorFlow only).

This function has been moved to tf_utils.py as it’s TensorFlow-specific. This wrapper is kept for backward compatibility.

signxai.utils.utils.load_image(img_path, target_size=(224, 224), expand_dims=False, use_original_preprocessing=True)[source]

Load an image from a file path and preprocess it.

This function has been moved to tf_utils.py as it uses TensorFlow preprocessing. This wrapper is kept for backward compatibility.

signxai.utils.utils.download_image(path)[source]

Download example image if it doesn’t exist

Parameters:

path – Path to save the image

signxai.utils.utils.download_model(path)[source]

Download example model if it doesn’t exist

Parameters:

path – Path to save the model

Module contents