visualization tool for tensor in CNN
Project description
visactivation
Written by YudeWang
A simple visualization tool for tensor activation in CNN.
Install
pip install visactivation
Document
visactivation.Tensor2Color(tensor, input_type=None, image=None, image_weight=0.3, colormap=cv2.COLORMAP_JET, act_type='max', norm_type='all')
Coloring the feature map in CNN to visualize the corresponding activation intensity.
Parameters:
- tensor (numpy.ndarray) - the input tensor for visualization
- input_type (str) - 'NCHW', 'NHW','CHW','HW'. When tensor.ndim == 3, input_type must be given.
- image (numpy.ndarray, optional) - corresponding image with size NHW3 or HW3
- image_weight (float, optional) - weight of image when visualization activation
- colormap (int, str)
- int - cv2.COLORMAP_xxx can be used here
- str - 'voc' PASCAL VOC colormap, 'random' Random colormap
- act_type (str) - 'sum', 'max', 'mean', 'none'.
- 'sum' - choose the sum value in channel dimension for each spatial pixel
- 'max' - choose the max value in channel dimension for each spatial pixel
- 'mean' - choose the mean value in channel dimension for each spatial pixel
- 'none' - preseve the activation of C channels and visualize them independently.
- norm_type (str) - 'relu','all'.
- 'relu' - tensor[tensor<0]=0, tensor/max(tensor)
- 'all' - (tensor-min)/(max-min)
Return:
N x C x H x W x 3 size numpy ndarray
visactivation.Prob2Color(tensor, input_type=None, image=None, image_weight=0.3, colormap=cv2.COLORMAP_JET, act_type='max')
Coloring the probability map in CNN to visualize the corresponding activation intensity.
Parameters:
- tensor (numpy.ndarray) - the input tensor for visualization, the value should in range [0,1]
- input_type (str) - 'NCHW', 'NHW','CHW','HW'. When tensor.ndim == 3, input_type must be given.
- image (numpy.ndarray, optional) - corresponding image with size NHW3 or HW3
- image_weight (float, optional) - weight of image when visualization activation
- colormap (int, str)
- int - cv2.COLORMAP_xxx can be used here
- str - 'voc' PASCAL VOC colormap, 'random' Random colormap
- act_type (str) - 'sum', 'max', 'mean', 'none'.
- 'sum' - choose the sum value in channel dimension for each spatial pixel. The result larger than 1 is cut off to 1.
- 'max' - choose the max value in channel dimension for each spatial pixel
- 'mean' - choose the mean value in channel dimension for each spatial pixel
- 'none' - preseve the activation of C channels and visualize them independently.
Return:
N x C x H x W x 3 size numpy ndarray
visactivation.Label2Color(tensor, image=None, image_weight=0.3, colormap='random')
Coloring the label map predicted by to visualize the corresponding activation intensity.
Parameters:
- tensor (numpy.ndarray) - the input label for visualization, the value should in be positive integer in [0, 255].
- image (numpy.ndarray, optional) - corresponding image with size NHW3 or HW3
- image_weight (float, optional) - weight of image when visualization activation
- colormap (str) - 'voc' PASCAL VOC colormap, 'random' Random colormap
Return:
N x H x W x 3 size numpy ndarray
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
visactivation-0.0.1.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for visactivation-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d219a957db8ed5e86abd67b783483c6514a8dfe0955a94569db3b1fa6a9188a5 |
|
MD5 | fe8b370de260fd2240692d971dcb20b0 |
|
BLAKE2b-256 | dec17d41bf00ae58dacefef08299f0411c0c78aa02924ae06912c56030a25fe9 |