nielsr HF staff commited on
Commit
85645ce
1 Parent(s): 563cf6b

Update code example

Browse files
Files changed (1) hide show
  1. README.md +4 -4
README.md CHANGED
@@ -31,13 +31,13 @@ Here is how to use this model for semantic segmentation:
31
 
32
  ```python
33
  from transformers import BeitFeatureExtractor, BeitForSemanticSegmentation
 
34
  from PIL import Image
35
- import requests
36
 
37
- url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
38
- image = Image.open(requests.get(url, stream=True).raw)
39
 
40
- feature_extractor = BeitFeatureExtractor(do_resize=True, size=640, do_center_crop=False)
41
  model = BeitForImageClassification.from_pretrained('microsoft/beit-base-finetuned-ade-640-640')
42
 
43
  inputs = feature_extractor(images=image, return_tensors="pt")
 
31
 
32
  ```python
33
  from transformers import BeitFeatureExtractor, BeitForSemanticSegmentation
34
+ from datasets import load_dataset
35
  from PIL import Image
 
36
 
37
+ # load ADE20k image
38
+ ds = load_dataset("hf-internal-testing/fixtures_ade20k", split="test")
39
 
40
+ feature_extractor = BeitFeatureExtractor.from_pretrained('microsoft/beit-base-finetuned-ade-640-640')
41
  model = BeitForImageClassification.from_pretrained('microsoft/beit-base-finetuned-ade-640-640')
42
 
43
  inputs = feature_extractor(images=image, return_tensors="pt")