alih
commited on
Commit
•
db8168a
1
Parent(s):
650219d
Update model name
Browse files- README.md +18 -7
- config.json +1 -1
README.md
CHANGED
@@ -14,7 +14,7 @@ widget:
|
|
14 |
example_title: Palace
|
15 |
---
|
16 |
|
17 |
-
# NAT (mini variant)
|
18 |
|
19 |
NAT-Mini trained on ImageNet-1K at 224x224 resolution.
|
20 |
It was introduced in the paper [Neighborhood Attention Transformer](https://arxiv.org/abs/2204.07143) by Hassani et al. and first released in [this repository](https://github.com/SHI-Labs/Neighborhood-Attention-Transformer).
|
@@ -38,20 +38,20 @@ NA is implemented in PyTorch implementations through its extension, [NATTEN](htt
|
|
38 |
You can use the raw model for image classification. See the [model hub](https://huggingface.co/models?search=nat) to look for
|
39 |
fine-tuned versions on a task that interests you.
|
40 |
|
41 |
-
###
|
42 |
|
43 |
-
Here is how to use this model to classify an image
|
44 |
|
45 |
```python
|
46 |
-
from transformers import
|
47 |
from PIL import Image
|
48 |
import requests
|
49 |
|
50 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
51 |
image = Image.open(requests.get(url, stream=True).raw)
|
52 |
|
53 |
-
feature_extractor =
|
54 |
-
model =
|
55 |
|
56 |
inputs = feature_extractor(images=image, return_tensors="pt")
|
57 |
outputs = model(**inputs)
|
@@ -61,7 +61,18 @@ predicted_class_idx = logits.argmax(-1).item()
|
|
61 |
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
62 |
```
|
63 |
|
64 |
-
For more
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
### BibTeX entry and citation info
|
67 |
|
|
|
14 |
example_title: Palace
|
15 |
---
|
16 |
|
17 |
+
# NAT (mini variant)
|
18 |
|
19 |
NAT-Mini trained on ImageNet-1K at 224x224 resolution.
|
20 |
It was introduced in the paper [Neighborhood Attention Transformer](https://arxiv.org/abs/2204.07143) by Hassani et al. and first released in [this repository](https://github.com/SHI-Labs/Neighborhood-Attention-Transformer).
|
|
|
38 |
You can use the raw model for image classification. See the [model hub](https://huggingface.co/models?search=nat) to look for
|
39 |
fine-tuned versions on a task that interests you.
|
40 |
|
41 |
+
### Example
|
42 |
|
43 |
+
Here is how to use this model to classify an image from the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
44 |
|
45 |
```python
|
46 |
+
from transformers import AutoImageProcessor, NatForImageClassification
|
47 |
from PIL import Image
|
48 |
import requests
|
49 |
|
50 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
51 |
image = Image.open(requests.get(url, stream=True).raw)
|
52 |
|
53 |
+
feature_extractor = AutoImageProcessor.from_pretrained("shi-labs/nat-mini-in1k-224")
|
54 |
+
model = NatForImageClassification.from_pretrained("shi-labs/nat-mini-in1k-224")
|
55 |
|
56 |
inputs = feature_extractor(images=image, return_tensors="pt")
|
57 |
outputs = model(**inputs)
|
|
|
61 |
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
62 |
```
|
63 |
|
64 |
+
For more examples, please refer to the [documentation](https://huggingface.co/transformers/model_doc/nat.html#).
|
65 |
+
|
66 |
+
### Requirements
|
67 |
+
Other than transformers, this model requires the [NATTEN](https://shi-labs.com/natten) package.
|
68 |
+
|
69 |
+
If you're on Linux, you can refer to [shi-labs.com/natten](https://shi-labs.com/natten) for instructions on installing with pre-compiled binaries (just select your torch build to get the correct wheel URL).
|
70 |
+
|
71 |
+
You can alternatively use `pip install natten` to compile on your device, which may take up to a few minutes.
|
72 |
+
Mac users only have the latter option (no pre-compiled binaries).
|
73 |
+
|
74 |
+
Refer to [NATTEN's GitHub](https://github.com/SHI-Labs/NATTEN/) for more information.
|
75 |
+
|
76 |
|
77 |
### BibTeX entry and citation info
|
78 |
|
config.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"architectures": [
|
3 |
-
"
|
4 |
],
|
5 |
"attention_probs_dropout_prob": 0.0,
|
6 |
"depths": [
|
|
|
1 |
{
|
2 |
"architectures": [
|
3 |
+
"NatForImageClassification"
|
4 |
],
|
5 |
"attention_probs_dropout_prob": 0.0,
|
6 |
"depths": [
|