Skip to content

Commit

Permalink
[DocTests] Fix some doc tests (huggingface#16889)
Browse files Browse the repository at this point in the history
* [DocTests] Fix some doc tests

* hacky fix

* correct
  • Loading branch information
patrickvonplaten authored Apr 23, 2022
1 parent 22fc93c commit 72728be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions docs/source/en/model_doc/t5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ The example above only shows a single example. You can also do batched inference
>>> model = T5ForConditionalGeneration.from_pretrained("t5-small")

>>> task_prefix = "translate English to German: "
>>> sentences = [
... "The house is wonderful.",
... "I like to work in NYC.",
>>> ] # use different length sentences to test batching
>>> # use different length sentences to test batching
>>> sentences = ["The house is wonderful.", "I like to work in NYC."]

>>> inputs = tokenizer([task_prefix + sentence for sentence in sentences], return_tensors="pt", padding=True)

>>> output_sequences = model.generate(
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/models/beit/modeling_beit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,14 +1210,14 @@ def forward(
Examples:
```python
>>> from transformers import BeitFeatureExtractor, BeitForSemanticSegmentation
>>> from transformers import AutoFeatureExtractor, BeitForSemanticSegmentation
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(url, stream=True).raw)
>>> feature_extractor = BeitFeatureExtractor.from_pretrained("microsoft/beit-base-finetuned-ade-640-640")
>>> feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/beit-base-finetuned-ade-640-640")
>>> model = BeitForSemanticSegmentation.from_pretrained("microsoft/beit-base-finetuned-ade-640-640")
>>> inputs = feature_extractor(images=image, return_tensors="pt")
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/models/data2vec/modeling_data2vec_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,14 +1140,14 @@ def forward(
Examples:
```python
>>> from transformers import Data2VecVisionFeatureExtractor, Data2VecVisionForSemanticSegmentation
>>> from transformers import AutoFeatureExtractor, Data2VecVisionForSemanticSegmentation
>>> from PIL import Image
>>> import requests
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(url, stream=True).raw)
>>> feature_extractor = Data2VecVisionFeatureExtractor.from_pretrained("facebook/data2vec-vision-base")
>>> feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/data2vec-vision-base")
>>> model = Data2VecVisionForSemanticSegmentation.from_pretrained("facebook/data2vec-vision-base")
>>> inputs = feature_extractor(images=image, return_tensors="pt")
Expand Down

0 comments on commit 72728be

Please sign in to comment.