Update README.md
Browse files
README.md
CHANGED
@@ -6,3 +6,57 @@ library_name: timm
|
|
6 |
license: apache-2.0
|
7 |
---
|
8 |
# Model card for kat_base_patch16_224
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
license: apache-2.0
|
7 |
---
|
8 |
# Model card for kat_base_patch16_224
|
9 |
+
|
10 |
+
KAT model trained on ImageNet-1k (1 million images, 1,000 classes) at resolution 224x224. It was first introduced in the paper Kolmogorov–Arnold Transformer.
|
11 |
+
|
12 |
+
## Model description
|
13 |
+
KAT is a model that replaces channel mixer in transfomrers with Group Rational Kolmogorov–Arnold Network (GR-KAN).
|
14 |
+
|
15 |
+
## Usage
|
16 |
+
The model definition is at https://github.com/Adamdad/kat, `katransformer.py`.
|
17 |
+
|
18 |
+
```python
|
19 |
+
from urllib.request import urlopen
|
20 |
+
from PIL import Image
|
21 |
+
import timm
|
22 |
+
import torch
|
23 |
+
import katransformer
|
24 |
+
|
25 |
+
img = Image.open(urlopen(
|
26 |
+
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
27 |
+
))
|
28 |
+
|
29 |
+
# Move model to CUDA
|
30 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
31 |
+
|
32 |
+
model = timm.create_model("hf_hub:adamdad/kat_base_patch16_224", pretrained=True)
|
33 |
+
model = model.to(device)
|
34 |
+
model = model.eval()
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
# get model specific transforms (normalization, resize)
|
39 |
+
data_config = timm.data.resolve_model_data_config(model)
|
40 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
41 |
+
|
42 |
+
output = model(transforms(img).unsqueeze(0).to(device)) # unsqueeze single image into batch of 1
|
43 |
+
|
44 |
+
top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
|
45 |
+
print(top5_probabilities)
|
46 |
+
print(top5_class_indices)
|
47 |
+
|
48 |
+
```
|
49 |
+
|
50 |
+
## Bibtex
|
51 |
+
```bibtex
|
52 |
+
@misc{yang2024compositional,
|
53 |
+
title={Kolmogorov–Arnold Transformer},
|
54 |
+
author={Xingyi Yang and Xinchao Wang},
|
55 |
+
year={2024},
|
56 |
+
eprint={XXXX},
|
57 |
+
archivePrefix={arXiv},
|
58 |
+
primaryClass={cs.CV}
|
59 |
+
}
|
60 |
+
```
|
61 |
+
|
62 |
+
|