Update README.md

This commit is contained in:
Niels Rogge 2023-02-27 15:07:09 +00:00 committed by huggingface-web
parent f5104f67a0
commit e8f8d2042c
1 changed files with 3 additions and 3 deletions

View File

@ -31,17 +31,17 @@ fine-tuned versions on a task that interests you.
Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes: Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
```python ```python
from transformers import AutoFeatureExtractor, ResNetForImageClassification from transformers import AutoImageProcessor, ResNetForImageClassification
import torch import torch
from datasets import load_dataset from datasets import load_dataset
dataset = load_dataset("huggingface/cats-image") dataset = load_dataset("huggingface/cats-image")
image = dataset["test"]["image"][0] image = dataset["test"]["image"][0]
feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50") processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
model = ResNetForImageClassification.from_pretrained("microsoft/resnet-50") model = ResNetForImageClassification.from_pretrained("microsoft/resnet-50")
inputs = feature_extractor(image, return_tensors="pt") inputs = processor(image, return_tensors="pt")
with torch.no_grad(): with torch.no_grad():
logits = model(**inputs).logits logits = model(**inputs).logits