sar-gupta / gradcam-pytorch

Implementation of GradCAM algorithm in Pytorch
7 stars 1 forks source link

GradCAM does not match exactly. Why? #1

Closed bemoregt closed 6 years ago

bemoregt commented 6 years ago

Hi, @sar-gupta

As a result of classifying with Resnet, Accuarcy is over 99%. If you hit map the object area with gradCAM with that model file, it does not match exactly. Why? it does not match exactly. Why?

It seems to be a problem of GradCAM rather than Resnet classification learning. The objects to be hit-mapped are not as local or blob like dogs or cats, but close to a long straight line. In this case, GradCAM seems to miss the object area. Have you experienced this?

For a well-trainedd Resnet34 model, how do you optimize GradCAM?

Thanks, in advance.

from @bemoregt.

sar-gupta commented 6 years ago

Hey @bemoregt, Can you please attach a screenshot of the same?

bemoregt commented 6 years ago

06a6fde4-dd58-4a66-947b-e26f049de7fd

bemoregt commented 6 years ago

3a6950cf-a0e6-44e3-963f-f14eacc80420

sar-gupta commented 6 years ago

What is the classification label for this image? @bemoregt

bemoregt commented 6 years ago

@sar-gupta, label is "line".

in lables, 0:"normal", 1:"line", 2:"hole"

sar-gupta commented 6 years ago

@bemoregt Can you check running gradcam with an image that has just one line, instead of multiple lines, and share the result?

bemoregt commented 6 years ago

@sar-gupta

Those Horizontal lines are just background. Diagonal line is a only defect object which I want to find.

Is that background lines are critical obstacle for real object heat mapping?

bemoregt commented 6 years ago

@sar-gupta

I using target layer 4.2 or 4.1:

CONFIG = {
    'resnet34': {
        'target_layer': 'layer4.2',
        'input_size': 224
    },
    # Add your model
}.get(arch)
sar-gupta commented 6 years ago

@bemoregt Can you tell me the prediction acore for an image with just the horizontal lines (background) without any diagonal line?

sar-gupta commented 6 years ago

@bemoregt Can you tell me the prediction score for an image with just the horizontal lines (background) without any diagonal line?

bemoregt commented 6 years ago

@sar-gupta

Normal class Classification Accuray Score may be 99.8% .. line or hole classes Accuarcys are same.

GuidedBackpropagation mapping method is more capable than grad-CAM for my image data?

sar-gupta commented 6 years ago

@bemoregt "line or hole classes Accuarcys are same." I don't understand what you mean by this

Can you answer a few questions:

  1. Have you changed the architecture of resnet to have only three output units?
  2. Have you trained the changed resnet with your own training data? If so, how many samples did you train it on?
  3. The sum of all predictions should be 100%. Are you passing the output prediction scores through a softmax?
bemoregt commented 6 years ago

@sar-gupta,

Yes,

Can you answer a few questions:

1.Have you changed the architecture of resnet to have only three output units?

  • I have using transfer learning with resnet(3-outpou FC layer) + pretrained imagenet.

2.Have you trained the changed resnet with your own training data? If so, how many samples did you train it on?

  • About 5000 images per classes. Data augmented.

3.The sum of all predictions should be 100%. Are you passing the output prediction scores through a softmax?

  • Yes, of course. all prediction sum is 100%. AUC of (line correct)/total is about 99.8%, I mean.
sar-gupta commented 6 years ago

@bemoregt Okay

I need two more things for now to help you with troubleshooting.

Softmax scores of all three classes for the following:

  1. Image with diagonal line in it.
  2. Image without diagonal line.

Both of these should have the horizontal lines as background.

Thanks

bemoregt commented 6 years ago

@sar-gupta

1.Image with diagonal line in it. >> Line Class
2.Image without diagonal line. >> Nomal class

Both scores are nearly 0.998 (softmax).

Thanks.

sar-gupta commented 6 years ago

@bemoregt Kindly provide the softmax scores for all three classes in both the cases.

To clarify, by softmax score, I mean the three outputs from softmax layer.

sar-gupta commented 6 years ago

Closing because the issue is not related to this project. However, discussion can be continued here.