-
Notifications
You must be signed in to change notification settings - Fork 3
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
Issue with ViT in BioClip Visual Part: ViT Returns CLS Token Instead of Logits #52
Comments
@Link7808 Do you have some example code that reproduces this issue? Is the BaseCAM class from https://github.com/jacobgil/pytorch-grad-cam ? If so I have a first attempt jupyter notebook that uses pytorch-grad-cam with pybioclip. |
@johnbradley |
@Link7808 After looking through the gradcam code I see what you mean about it expecting a different output. The changes I made where:
The above code will print out the target number and label associated with it. Outside of adding a couple imports the only other changes were to instantiate the new model and set target_layers.
|
I noticed you’re using eigencam. Do you have any thoughts on why Grad-CAM is performing poorly? |
@Link7808 I've found setting Help for eigen_smooth in vit_example.py says
This pytorch_grad_cam code seems to be where the eigen_smooth flag takes effect. |
I'm not sure why without |
We are using the visual part (ViT) of BioClip to process images. However, there is an issue with the forward method in BaseCAM.
In the following line of code:
self.outputs = outputs = self.activations_and_grads(input_tensor)
target_categories = np.argmax(outputs.cpu().data.numpy(), axis=-1)
The outputs in this case is the CLS token embedding, which is a high-dimensional vector used to represent the global semantic information of the input image. This embedding is not a classification result or logits, but rather a feature vector.
The text was updated successfully, but these errors were encountered: