File size: 13,210 Bytes
6470ffe
 
673e2d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6470ffe
e9ab73a
673e2d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9ab73a
673e2d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
---
license: apache-2.0
language:
- en
tags:
- biology
- CV
- images
- animals
- image classification
- fine-grained classification
- butterflies
- birds
- interpretable
- transformers
- cross-attention
metrics:
---

<!--

NOTE: Add more tags (your particular animal, type of model and use-case, etc.).

Fill in as much information as you can at each location that says "More information needed".
-->


<!--
Image with caption:
|![Figure #](https://huggingface.co/imageomics/<model-repo>/resolve/main/<filename>)|
|:--|
|**Figure #.** [Image of <>](https://huggingface.co/imageomics/<model-repo>/raw/main/<filename>) <caption description>.|
-->

<!--
Notes on styling:

To render LaTex in your README, wrap the code in `\\(` and `\\)`. Example: \\(\frac{1}{2}\\)

Escape underscores ("_") with a "\". Example: image\_RGB
-->

# Model Card for INTR: A Simple Interpretable Transformer for Fine-grained Image Classification and Analysis


INTR checkpoint on CUB dataset with backbone DETR-R50 <!-- Also used Kaggle Birds and Cambridge Butterfly (should be noted as subset of images from the Butterfly Genetics Group, see https://huggingface.co/datasets/imageomics/Jiggins_Heliconius_Collection)
-->

<!-- This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1). And further altered to suit Imageomics Institute needs -->

## Model Details

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Developed by:** Dipanjyoti Paul, Arpita Chowdhury, Xinqi Xiong, Feng-Ju Chang, David Carlyn, Samuel Stevens, Kaiya Provost, Anuj Karpatne, Bryan Carstens, Daniel Rubenstein, Charles Stewart, Tanya Berger-Wolf, Yu Su, and Wei-Lun Chao
- **Shared by [optional]:** [More Information Needed]
- **Model type:** [More Information Needed] <!-- Transformer -->
- **License:** Apache 2.0
- **Fine-tuned from model:** [DETR-R50](https://github.com/facebookresearch/detr)

### Model Sources

<!-- Provide the basic links for the model. -->

- **Repository:** [Imageomics/INTR](https://github.com/Imageomics/INTR)
- **Paper:** [A Simple Interpretable Transformer for Fine-Grained Image Classification and Analysis](https://doi.org/10.48550/arXiv.2311.04157)
- **Demo:** [Inference time single-image prediction and visualization notebook](https://github.com/Imageomics/INTR/blob/main/demo.ipynb). Note that this is focused on the CUB dataset.

<!-- I assume the demo could be adjusted to work with either of the other datasets by adjusting a few parameters? If so, please note, otherwise indicate that it is not so simple -->

## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->

### Direct Use

<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->

[More Information Needed]

### Downstream Use [optional]

<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->

[More Information Needed]

### Out-of-Scope Use

<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->

[More Information Needed]

## Bias, Risks, and Limitations

<!-- This section is meant to convey both technical and sociotechnical limitations. -->

[More Information Needed]

### Recommendations

<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->

Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.

## How to Get Started with the Model

Use the code below to get started with the model.

<!-- Put code here or links to files to run. Set up code blocks like this:
```
<code here>
```
-->

[More Information Needed]

## Training Details

### Training Data

<!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering.
In this case, at least add information and link specifically to the training sets for CUB & Kaggle Birds (assuming that's what was used).
Also, preprocessing on these images needs to be described (eg., resizing). -->

[More Information Needed]

| Model | Dataset |
|----------|----------|
|  [CUB checkpoint download](https://huggingface.co/imageomics/INTR/resolve/main/intr_checkpoint_cub_detr_r50.pth)| [CUB](https://www.vision.caltech.edu/datasets/cub_200_2011/) [More Information Needed]<!-- What was the training data? --> |
|  [Bird checkpoint download](https://huggingface.co/imageomics/INTR/resolve/main/intr_checkpoint_bird_detr_r50.pth) | [Birds 525](https://www.kaggle.com/datasets/gpiosenka/100-bird-species) [More Information Needed]<!-- What was the training data? --> |
| [Butterfly checkpoint download](https://huggingface.co/imageomics/INTR/resolve/main/intr_checkpoint_butterfly_detr_r50.pth) | [Cambridge Butterfly](https://huggingface.co/datasets/imageomics/Cambridge_butterfly), images in the `train` folder |


### Training Procedure 

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
[More Information Needed]

Follow the below format for data.
```
datasets
β”œβ”€β”€ dataset_name
β”‚   β”œβ”€β”€ train
β”‚   β”‚   β”œβ”€β”€ class1
β”‚   β”‚   β”‚   β”œβ”€β”€ img1.jpeg
β”‚   β”‚   β”‚   β”œβ”€β”€ img2.jpeg
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ class2
β”‚   β”‚   β”‚   β”œβ”€β”€ img3.jpeg
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   └── ...
β”‚   └── val
β”‚       β”œβ”€β”€ class1
β”‚       β”‚   β”œβ”€β”€ img4.jpeg
β”‚       β”‚   β”œβ”€β”€ img5.jpeg
β”‚       β”‚   └── ...
β”‚       β”œβ”€β”€ class2
β”‚       β”‚   β”œβ”€β”€ img6.jpeg
β”‚       β”‚   └── ...
β”‚       └── ...
```

#### Preprocessing [optional]

[More Information Needed]


#### Training Hyperparameters

- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->

#### Speeds, Sizes, Times [optional]

<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->

[More Information Needed]

## Evaluation

<!-- This section describes the evaluation protocols and provides the results. -->

To evaluate the performance of INTR on the _CUB_ dataset, on a multi-GPU (e.g., 4 GPUs) settings, execute the below command. INTR checkpoints are available at Fine-tune model and results.

```sh
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port 12345 --use_env main.py --eval --resume <path/to/intr_checkpoint_cub_detr_r50.pth> --dataset_path <path/to/datasets> --dataset_name <dataset_name> 
```

Similarly, replace `cub` in the name of the checkpoint with `bird` or `butterfly` to evaluate with the Birds 525 or Cambridge Butterfly checkpoint, respectively.

### Testing Data, Factors & Metrics

#### Testing Data

<!-- This should link to a Data Card if possible.
In this case, at least add information and link specifically to the test sets for CUB & Kaggle Birds (assuming that's what was used) -->

[More Information Needed]

| Model | Dataset |
|----------|----------|
|  [CUB checkpoint download](https://huggingface.co/imageomics/INTR/resolve/main/intr_checkpoint_cub_detr_r50.pth)| [CUB](https://www.vision.caltech.edu/datasets/cub_200_2011/) [More Information Needed]<!-- What was the test data? --> |
|  [Birds checkpoint download](https://huggingface.co/imageomics/INTR/resolve/main/intr_checkpoint_bird_detr_r50.pth) | [Birds 525](https://www.kaggle.com/datasets/gpiosenka/100-bird-species) [More Information Needed]<!-- What was the test data? --> |
| [Butterfly checkpoint download](https://huggingface.co/imageomics/INTR/resolve/main/intr_checkpoint_butterfly_detr_r50.pth) | [Cambridge Butterfly](https://huggingface.co/datasets/imageomics/Cambridge_butterfly), images in the `val` folder |


#### Factors

<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->

[More Information Needed]

#### Metrics

<!-- These are the evaluation metrics being used, ideally with a description of why. -->

[More Information Needed]

### Results


| Dataset | acc@1 | acc@5 |
|----------|----------|----------|
| [CUB](https://www.vision.caltech.edu/datasets/cub_200_2011/) | 71.8 | 89.3 | 
| [Birds 525](https://www.kaggle.com/datasets/gpiosenka/100-bird-species) | 97.4 | 99.2 | 
| [Butterfly](https://huggingface.co/datasets/imageomics/Cambridge_butterfly) | 95.0 | 98.3 | 


#### Summary

[More Information Needed]

## Model Examination [optional]

<!-- Relevant interpretability work for the model goes here -->

[More Information Needed]

## Environmental Impact

<!-- 
It would be great to try to include this.

Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->

Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://doi.org/10.48550/arXiv.1910.09700).

- **Hardware Type:** [More Information Needed]
- **Hours used:** [More Information Needed]
- **Cloud Provider:** [More Information Needed]
- **Compute Region:** [More Information Needed]
- **Carbon Emitted:** [More Information Needed]

## Technical Specifications [optional]

### Model Architecture and Objective

[More Information Needed]

### Compute Infrastructure

[More Information Needed]

#### Hardware

[More Information Needed]

#### Software

[More Information Needed]

## Citation

<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->

**BibTeX:**

[![Paper](https://img.shields.io/badge/Paper-10.48550%2FarXiv.2311.04157-blue)](https://doi.org/10.48550/arXiv.2311.04157)
If you find our work helpful for your research, please consider citing our paper as well. 
```
@article{paul2023simple,
  title={A Simple Interpretable Transformer for Fine-Grained Image Classification and Analysis},
  author={Paul, Dipanjyoti and Chowdhury, Arpita and Xiong, Xinqi and Chang, Feng-Ju and Carlyn, David and Stevens, Samuel and Provost, Kaiya and Karpatne, Anuj and Carstens, Bryan and Rubenstein, Daniel and Stewart, Charles and Berger-Wolf, Tanya and Su, Yu and Chao, Wei-Lun},
  journal={arXiv preprint arXiv:2311.04157},
  year={2023}
}
```

Model Citation:
```
@software{Paul_A_Simple_Interpretable_2023,
  author = {Paul, Dipanjyoti and Chowdhury, Arpita and Xiong, Xinqi and Chang, Feng-Ju and Carlyn, David and Stevens, Samuel and Provost, Kaiya and Karpatne, Anuj and Carstens, Bryan and Rubenstein, Daniel and Stewart, Charles and Berger-Wolf, Tanya and Su, Yu and Chao, Wei-Lun},
  license = {Apache-2.0},
  title = {{A Simple Interpretable Transformer for Fine-Grained Image Classification and Analysis}},
  doi = {<doi once generated>},
  url = {https://huggingface.co/imageomics/INTR},
  version = {1.0.0},
  month = sep,
  year = {2023}
}

```


**APA:** <!--optional-->

Paper:

Paul, D., Chowdhury, A., Xiong, X., Chang, F., Carlyn, D., Stevens, S., Provost, K., Karpatne, A., Carstens, B., Rubenstein, D., Stewart, C., Berger-Wolf, T., Su, Y., & Chao, W. (2023). A Simple Interpretable Transformer for Fine-Grained Image Classification and Analysis. arXiv. https://doi.org/10.48550/arXiv.2311.04157.


Model Citation:

Paul, D., Chowdhury, A., Xiong, X., Chang, F., Carlyn, D., Stevens, S., Provost, K., Karpatne, A., Carstens, B., Rubenstein, D., Stewart, C., Berger-Wolf, T., Su, Y., & Chao, W. (2023). A Simple Interpretable Transformer for Fine-Grained Image Classification and Analysis (Version 1.0.0). <!--Add DOI once generated -->

## Acknowledgements

Our model is inspired by the DEtection TRansformer [(DETR)](https://github.com/facebookresearch/detr) method.

We thank the authors of DETR for doing such great work.

The [Imageomics Institute](https://imageomics.org) is funded by the US National Science Foundation's Harnessing the Data Revolution (HDR) program under [Award #2118240](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2118240) (Imageomics: A New Frontier of Biological Information Powered by Knowledge-Guided Machine Learning). Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

## Glossary [optional]

<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->

[More Information Needed]

## More Information [optional]

[More Information Needed]

## Model Card Authors [optional]

[More Information Needed]

## Model Card Contact

[More Information Needed]