Update README.md
Browse files
README.md
CHANGED
@@ -31,17 +31,17 @@ fine-tuned versions on a task that interests you.
|
|
31 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
32 |
|
33 |
```python
|
34 |
-
from transformers import
|
35 |
import torch
|
36 |
from datasets import load_dataset
|
37 |
|
38 |
dataset = load_dataset("huggingface/cats-image")
|
39 |
image = dataset["test"]["image"][0]
|
40 |
|
41 |
-
|
42 |
model = ResNetForImageClassification.from_pretrained("microsoft/resnet-50")
|
43 |
|
44 |
-
inputs =
|
45 |
|
46 |
with torch.no_grad():
|
47 |
logits = model(**inputs).logits
|
|
|
31 |
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
|
32 |
|
33 |
```python
|
34 |
+
from transformers import AutoImageProcessor, ResNetForImageClassification
|
35 |
import torch
|
36 |
from datasets import load_dataset
|
37 |
|
38 |
dataset = load_dataset("huggingface/cats-image")
|
39 |
image = dataset["test"]["image"][0]
|
40 |
|
41 |
+
processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
|
42 |
model = ResNetForImageClassification.from_pretrained("microsoft/resnet-50")
|
43 |
|
44 |
+
inputs = processor(image, return_tensors="pt")
|
45 |
|
46 |
with torch.no_grad():
|
47 |
logits = model(**inputs).logits
|