nielsr HF staff commited on
Commit
9da3011
1 Parent(s): e10357e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -3
README.md CHANGED
@@ -33,14 +33,17 @@ fine-tuned versions on a task that interests you.
33
  Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
34
 
35
  ```python
36
- from transformers import BeitFeatureExtractor, BeitForImageClassification
37
  from PIL import Image
38
  import requests
 
39
  url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
40
  image = Image.open(requests.get(url, stream=True).raw)
41
- feature_extractor = BeitFeatureExtractor.from_pretrained('microsoft/beit-base-patch16-224-pt22k-ft22k')
 
42
  model = BeitForImageClassification.from_pretrained('microsoft/beit-base-patch16-224-pt22k-ft22k')
43
- inputs = feature_extractor(images=image, return_tensors="pt")
 
44
  outputs = model(**inputs)
45
  logits = outputs.logits
46
  # model predicts one of the 21,841 ImageNet-22k classes
 
33
  Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
34
 
35
  ```python
36
+ from transformers import BeitImageProcessor, BeitForImageClassification
37
  from PIL import Image
38
  import requests
39
+
40
  url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
41
  image = Image.open(requests.get(url, stream=True).raw)
42
+
43
+ processor = BeitImageProcessor.from_pretrained('microsoft/beit-base-patch16-224-pt22k-ft22k')
44
  model = BeitForImageClassification.from_pretrained('microsoft/beit-base-patch16-224-pt22k-ft22k')
45
+
46
+ inputs = processor(images=image, return_tensors="pt")
47
  outputs = model(**inputs)
48
  logits = outputs.logits
49
  # model predicts one of the 21,841 ImageNet-22k classes