-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is different between the models? #68
Comments
@xBorja042 , Thank you for your great idea! Thanks! |
@keisen Thanks a lot for your response. Thanks a lot and kind regards, Borja. |
The biggest difference between ScoreCAM and GradCAMs is whether it needs the gradient calculation.
https://github.com/keisen/tf-keras-vis/tree/master/examples Thanks! |
Thanks @keisen I understand what score is. What I do not understand is that why the methods need it as input and what to do if I am not using VGG16. |
@xBorja042 , could you clarify what the problem or the situation are? |
I have not experienced the problem yet. But I want to use your library to explain the experts how the model is working @keisen. I will try to explain to you better: Let us suppose that I have written my own model based on CONVs layers. The problem is that I do not have this part of the code: score = CategoricalScore([1, 294, 413]) This is because I am not going to use VGG16 but my own model to classify. The thing is if it is possible to adapt your library for ad-hoc models. Thanks for your patience and kind responses. |
@xBorja042 , the code below is a part of the example in README.md. # Create GradCAM++ object
gradcam = GradcamPlusPlus(YOUR_MODEL_INSTANCE,
model_modifier=ReplaceToLinear(),
clone=True)
# Generate cam with GradCAM++
cam = gradcam(CategoricalScore(CATEGORICAL_INDEX),
SEED_INPUT) Is the question that, also when Thanks! |
@keisen Do not say sorry! I feel very gratefull for your help. I am not sure that I have explained well. My question is about what to do when the model does not have a score like this: score = CategoricalScore([1, 294, 413]) The input for CategoricalScore is just the correct values assigned for the images? If so, I need to know what images am I using. Thanks again! |
@xBorja042 , okay, let's go next!
Here, please see the code that is a part of Attention Example Notebok. The implement below is equivalent to def score_function(output):
# The `output` variable refers to the output of the model,
# so, in this case, `output` shape is `(3, 1000)` i.e., (samples, classes).
return (output[0][1], output[1][294], output[2][413]) As you see above, it just returns the values of model output corresponding to [1, 294, 413].
So, all visualization algorisms NEED the score. Thanks! |
Good morning @keisen . Thanks a lot for your help! I think I do understand the idea. score = BinaryScore([model.predict(samples)[0],model.predict(samples)[1]]) |
In binary classification, when the model output shape is (batch_size, 2), please use CategoricalScore class to specify index of the category you want to visualize.
So, in this case, if you want to visualize the CAMs or Saliency maps corresponding to score = CategoricalScore([0, 1]) Or, function score_function(output):
return (output[0][0], output[1][1]) Both implements above are the same! gradcam = Gradcam(model, ...)
cam_image = gradcam(score, SEED_INPUT, ...)
# or, cam_image = gradcam(score_function, SEED_INPUT, ...) To understand how the score or tf-keras-vis work, I strongly recommend you to read the example notebooks of tf-keras-vis in examples folder and to experiment while modifying their code. (of course, before that, reading the papers of Gradcam, Gradcam++ and Scorecam would be also good!) When you face any error that you can't solve, please come back here and feel free to ask us! Thanks! |
All right @keisen . Thanks a lot for your help and sorry for the incoveniences. |
@xBorja042 , no problem! Thanks! |
Hello, I have a suggestion for you. Since you have implement the methods so you understand very well the ideas behind these methods I would recommend you to explain what are the main difference between the methods on the examples notebook. Just a short detail, that would very great.
Thanks and kind regards,
Borja.
The text was updated successfully, but these errors were encountered: