Open JamesCallanan opened 2 years ago
Hi, I have a question I'd like to clarify. Does this model, in conjunction with Grad-CAM, generate a heatmap for each "slice" of the input volume? In other words, is the technique applied individually to each slice of the three-dimensional dataset, creating heatmaps for each of them?
I found the issue. It is due to the resizing of the cam variable using skimage.transform.resize().
from skimage.transform import resize capi=resize(cam,(128,128,128))
This resizing implementation results in cam[ : , : , 0 ] equalling cam[ : , : , 1 ] and cam[ : , : , -1 ] equalling cam[ : , : , -2] for me.
Swapping the resizing function which relies on scipy.ndimage.zoom()) worked for me. Now each slice now is unique.
def resize_volume(img, desired_depth, desired_height, desired_width): """Resize across z-axis"""
Get current depth
current_depth = img.shape[-1] current_width = img.shape[0] current_height = img.shape[1]
Compute depth factor
depth = current_depth / desired_depth width = current_width / desired_width height = current_height / desired_height depth_factor = 1 / depth width_factor = 1 / width height_factor = 1 / height
Rotate
img = ndimage.rotate(img, 90, reshape=False)
Resize across z-axis
img = ndimage.zoom(img, (width_factor, height_factor, depth_factor), order=1) return img
capi = resize_volume(cam,128,128,128)
relevant file = guided_Gradcam3.py