Git Product home page Git Product logo

cwangrun / st-protopnet Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 1.0 861 KB

[ICCV 2023] Learning Support and Trivial Prototypes for Interpretable Image Classification

Home Page: https://openaccess.thecvf.com/content/ICCV2023/papers/Wang_Learning_Support_and_Trivial_Prototypes_for_Interpretable_Image_Classification_ICCV_2023_paper.pdf

Python 100.00%
fine-grained-classification interpretability-and-explainability interpretable-ai interpretable-deep-learning interpretable-neural-networks image-recognition explainable-ai

st-protopnet's Introduction

Learning Support and Trivial Prototypes for Interpretable Image Classification

Pytorch Implementation for the paper "Learning Support and Trivial Prototypes for Interpretable Image Classification" published at ICCV 2023.

In this work, we make an analogy between the prototype learning from ProtoPNet and support vector learning from SVM, and propose to learn support (i.e., hard-to-learn) prototypes, in comparison with trivial (i.e., easy-to-learn) prototypes, by forcing prototypes of different classes to locate near the classification boundary in the latent space (see figure above). In addition, we present the ST-ProtoPNet (see figure below) to exploit both support and trivial prototypes for complementary and interpretable image classification. Email: [email protected]

This repository is built mainly based on publicly available code from ProtoPNet and TesNet.

Datasets:

  1. Download CUB-200-2011, Stanford Cars, and Stanford Dogs.
  2. Crop images in CUB and Cars with the bounding-box information provided by the datasets: ./cropped/preprocess_data/cropimages.py.
  3. Augment images in the training set in an offline mode, see details in: ./cropped/preprocess_data/img_aug.py, then put them in train_dir, test_dir, ...
  4. Experiments using the raw full images in CUB and Dogs are also involved in this work, where the training images are augmented with online RandomAffine and RandomHorizontalFlip.

Train a model:

  1. For cropped CUB and Cars: python ./cropped/main.py. Specifying: gpuid, backbone architecture, dataset. Note we use projection metric to compute similarity between prototypes and features in cropped CUB and Cars, as in TesNet.
  2. For full CUB and Dogs: python ./full/main.py. Specifying: gpuid, backbone architecture, dataset. Note we use cosine similarity between prototypes and features for full CUB and Dogs, following Deformable ProtoPNet.

iNaturalist Pretrained ResNet-50. As in Deformable ProtoPNet and ProtoTree, we use iNaturalist-pretrained ResNet50 when training our model on full CUB-200-2011, since iNaturalist contains plants and animals and serves as a good source domain for recognising birds in CUB.

Interpretable reasoning:

  1. Run local_analysis.py to find the nearest support or trivial training prototypes to a test input image, where these prototypes (as well as their source training images) will be automatically retrieved and the similarity maps of the test image with these training prototypes will be computed to realise the similarity-based interpretability.

Other experiments:

  1. Measure interpretability using Intersection over Union (IoU), Content Heatmap (CH), Outside-Inside Relevance Ratio (OIRR), and Deletion AUC (DAUC).
  2. Since CH, IoU, and OIRR require object annotations, we extract the binary bird segmentation masks from full CUB-200-2011.
  3. Run ./full/interpretability, providing the following arguments: trained model path, test_dir, ground-truth mask path.

Citation:

@inproceedings{wang2023learning,
  title={Learning Support and Trivial Prototypes for Interpretable Image Classification},
  author={Wang, Chong and Liu, Yuyuan and Chen, Yuanhong and Liu, Fengbei and Tian, Yu and McCarthy, Davis J and Frazer, Helen and Carneiro, Gustavo},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={2062--2072},
  year={2023}
}

st-protopnet's People

Contributors

cwangrun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

taylorift

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.