Paper accepted at the AJCAI 2023(https://ajcai2023.org/index.html).
If you use this repository, please cite:
@inproceedings{li2023part,
title={Part-Aware Prototype-Aligned Interpretable Image Classification with Basic Feature Domain},
author={Li, Liangping and Gong, Xun and Wang, Chenzhong and Kong, Weiji},
booktitle={Australasian Joint Conference on Artificial Intelligence},
pages={185--196},
year={2023},
organization={Springer}
}
It is recommended to run PaProtoPNet on a multi-GPU machine to achieve better results.
Requirements: Pytorch, Numpy, cv2, Augmentor
Take the CUB-200-2011 as an example.
This version of code package was based on ProtoPNet (https://github.com/cfchen-duke/ProtoPNet) and TesNet(https://github.com/JackeyWang96/TesNet).
DataConfiger
in file PaProtoPNet/settings_CUB.py
. You can change the running GPU devices, dataset location, and more.self.feature_type = "cluster"
# self.feature_type = "row"
...
if model_name == "resnet152":
self.devices = [2, 3, 4, 5, 6, 7]
self.train_batch_size = 30
self.test_batch_size = 80
self.train_push_batch_size = 75
...
self.joint_optimizer_lrs = {'features': 1e-4,
'add_on_layers': 3e-3,
'prototype_vectors': 3e-3}
self.joint_lr_step_size = 2
self.warm_optimizer_lrs = {'add_on_layers': 3e-3,
'prototype_vectors': 3e-3}
self.last_layer_optimizer_lr = 1e-4
Set the mode of feature aggregation by self.feature_type
(row or cluster).
The dataset_name
in file PaProtoPNet/settings_CUB.py
can determine the dataset used for model training.
dataset_name = 'CUB'
# dataset_name = 'CUB_full'
# dataset_name = 'CAR'
CUB-200-2011 can be downloaded from: http://www.vision.caltech.edu/visipedia/CUB-200-2011.html
Stanford Cars can be downloaded from: https://ai.stanford.edu/~jkrause/cars/car_dataset.html
./preprocess_data/cropimages.py
The cropped training images in the directory: ./datasets/cub200_cropped/train_cropped/
The cropped test images in the directory: ./datasets/cub200_cropped/test_cropped/
./preprocess_data/img_aug.py
./datasets/cub200_cropped/train_cropped_augmented/
features/state_dicts
.preprocess_data
.Run PaProtoPNet/main_ProtoPNet.py
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。