peal.global_utils.generate_overlay¶
- peal.global_utils.generate_overlay(x, counterfactual, alpha_factor=2.0)[source]¶
Blend the change heatmap onto a washed-out copy of the image.
The original is turned greyscale and pulled towards 0.5 so that black and white areas read as grey, and the heatmap of
high_contrast_heatmap()is blended in with an alpha taken from its strongest channel.- Parameters:
x (
torch.Tensor) – A single image each, shape(C, H, W).counterfactual (
torch.Tensor) – A single image each, shape(C, H, W).alpha_factor (
float, optional) – Multiplier on the alpha mask; larger values make weaker changes opaque as well.
- Returns:
RGB overlay of shape
(3, H, W)in[0, 1].- Return type: