Update README.md
Browse files
README.md
CHANGED
@@ -32,14 +32,17 @@ You can use the raw model to embed images, but it's mostly intended to be fine-t
|
|
32 |
Here is how to use this model:
|
33 |
|
34 |
```python
|
35 |
-
from transformers import
|
36 |
from PIL import Image
|
37 |
import requests
|
|
|
38 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
39 |
image = Image.open(requests.get(url, stream=True).raw)
|
40 |
-
|
|
|
41 |
model = ViTModel.from_pretrained('google/vit-large-patch16-224-in21k')
|
42 |
-
|
|
|
43 |
outputs = model(**inputs)
|
44 |
last_hidden_state = outputs.last_hidden_state
|
45 |
```
|
|
|
32 |
Here is how to use this model:
|
33 |
|
34 |
```python
|
35 |
+
from transformers import ViTImageProcessor, ViTModel
|
36 |
from PIL import Image
|
37 |
import requests
|
38 |
+
|
39 |
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
|
40 |
image = Image.open(requests.get(url, stream=True).raw)
|
41 |
+
|
42 |
+
processor = ViTImageProcessor.from_pretrained('google/vit-large-patch16-224-in21k')
|
43 |
model = ViTModel.from_pretrained('google/vit-large-patch16-224-in21k')
|
44 |
+
|
45 |
+
inputs = processor(images=image, return_tensors="pt")
|
46 |
outputs = model(**inputs)
|
47 |
last_hidden_state = outputs.last_hidden_state
|
48 |
```
|