Update README.md
Browse files
README.md
CHANGED
@@ -39,17 +39,17 @@ fine-tuned versions on a task that interests you.
|
|
39 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
40 |
|
41 |
```python
|
42 |
-
from transformers import
|
43 |
from PIL import Image
|
44 |
import requests
|
45 |
|
46 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
47 |
image = Image.open(requests.get(url, stream=True).raw)
|
48 |
|
49 |
-
|
50 |
model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
|
51 |
|
52 |
-
inputs =
|
53 |
outputs = model(**inputs)
|
54 |
logits = outputs.logits
|
55 |
# model predicts one of the 1000 ImageNet classes
|
|
|
39 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
40 |
|
41 |
```python
|
42 |
+
from transformers import ViTImageProcessor, ViTForImageClassification
|
43 |
from PIL import Image
|
44 |
import requests
|
45 |
|
46 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
47 |
image = Image.open(requests.get(url, stream=True).raw)
|
48 |
|
49 |
+
processor = ViTImageProcessor.from_pretrained('google/vit-base-patch16-224')
|
50 |
model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
|
51 |
|
52 |
+
inputs = processor(images=image, return_tensors="pt")
|
53 |
outputs = model(**inputs)
|
54 |
logits = outputs.logits
|
55 |
# model predicts one of the 1000 ImageNet classes
|