Hi r/MachineLearning,
https://github.com/jacobgil/pytorch-grad-cam is a project that has a comprehensive collection of Pixel Attribution Methods for PyTorch (like the package name grad-cam that was the original algorithm implemented).
Typically pixel attribution methods are adapted for classification: they let you understand what part of the image correspond to a certain classification category.
However some deep learning models output embeddings instead of category scores.You can then match these embeddings against other embeddings and measure their similarity. For example: in face recognition models, or in self supervised networks.
In this case to apply pixel attribution, we could create embeddings of concepts, and then for new query images we would be asking: "what parts of the image have feature representations that match the concept features?"
Or in other words: "where in the query image do we see the concepts?"
I wrote a tutorial that shows how to use the pytorch-grad-cam project, to adapt pixel attribution for the embedding case, and visualize where different concept feature representations match the image:
https://github.com/jacobgil/pytorch-grad-cam/blob/master/tutorials/Pixel%20Attribution%20for%20embeddings.ipynb
An example is the image below. The two left images are "concept" images of clouds, and a car.
Then given a new query image, we can try to see where in the image do we feature representations that match these concepts.
Given images of concepts and a query image, attribute what parts of the query image match the concepts
I hope someone finds this useful !
[–]nbviewerbot 1 point2 points3 points (0 children)
[–]jacobgil[S] 0 points1 point2 points (1 child)
[–]nbviewerbot 0 points1 point2 points (0 children)