Update README.md
#4
by
jzhang533
- opened
README.md
CHANGED
@@ -34,14 +34,14 @@ Since this model is a more efficiently trained ViT model, you can plug it into V
|
|
34 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
35 |
|
36 |
```python
|
37 |
-
from transformers import
|
38 |
from PIL import Image
|
39 |
import requests
|
40 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
41 |
image = Image.open(requests.get(url, stream=True).raw)
|
42 |
-
|
43 |
model = ViTForImageClassification.from_pretrained('facebook/deit-tiny-patch16-224')
|
44 |
-
inputs =
|
45 |
outputs = model(**inputs)
|
46 |
logits = outputs.logits
|
47 |
# model predicts one of the 1000 ImageNet classes
|
|
|
34 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
35 |
|
36 |
```python
|
37 |
+
from transformers import AutoImageProcessor, ViTForImageClassification
|
38 |
from PIL import Image
|
39 |
import requests
|
40 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
41 |
image = Image.open(requests.get(url, stream=True).raw)
|
42 |
+
processor = AutoImageProcessor.from_pretrained("facebook/deit-tiny-patch16-224")
|
43 |
model = ViTForImageClassification.from_pretrained('facebook/deit-tiny-patch16-224')
|
44 |
+
inputs = processor(images=image, return_tensors="pt")
|
45 |
outputs = model(**inputs)
|
46 |
logits = outputs.logits
|
47 |
# model predicts one of the 1000 ImageNet classes
|