MECLabTUDA / M3d-Cam

MIT License
306 stars 40 forks source link

3D CNN for classification with gcam #23

Open nedleeds opened 2 years ago

nedleeds commented 2 years ago

Hi, first of all thank you for your dedication on this research area. It was really helped for me. But here's what I'm qurious about. I've made 3D model to classify the retinal disease, and I just extract the output of attention map which size is 8x6x6 from 256x192x192. I needed to use your interpolation function to make the attention map has sames shape with raw_input. The point is raw input data include a lot of zero values which is not considered in interpolating code. It means, even though zero area, attention map has been interpolated. So, is the any function that makes a proper interpolation based on the masked area?

AralRalud commented 1 year ago

hi @nedleeds, did you manage to solve this? I have the same issue...

nedleeds commented 1 year ago

hi @nedleeds, did you manage to solve this? I have the same issue...

I had just interpolated the attention map to the input size then overlayed on the input. I figured it out it was extracted correctly. Well, maybe you can check my code (https://github.com/nedleeds/OCTADeeplearning/blob/main/Medcam/medcam_utils.py).

AralRalud commented 1 year ago

Thanks for the reply, @nedleeds, I took a look at your code. It was helpful. However, I do want to add this link to this thread for anyone looking at this later. You can get attention map directly with the following code

# Use parameter 'return_attention' to get the prediction and the attention
model = medcam.inject(model, output_dir="attention_maps", save_maps=False, return_attention=True)
...
prediction, attention_map = model(input)

The attention_map here is alredy the same size as the input.