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