diff --git a/src/transformers/models/textnet/modeling_textnet.py b/src/transformers/models/textnet/modeling_textnet.py index 60080d36dfec51..f47ce5dc877096 100644 --- a/src/transformers/models/textnet/modeling_textnet.py +++ b/src/transformers/models/textnet/modeling_textnet.py @@ -346,9 +346,10 @@ def forward( Examples: ```python - >>> from transformers import TextNetForImageClassification,TextNetImageProcessor - >>> from PIL import Image + >>> import torch >>> import requests + >>> from transformers import TextNetForImageClassification, TextNetImageProcessor + >>> from PIL import Image >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" >>> image = Image.open(requests.get(url, stream=True).raw) @@ -357,7 +358,8 @@ def forward( >>> model = TextNetForImageClassification.from_pretrained("Raghavan/textnet-base") >>> inputs = processor(images=image, return_tensors="pt", size={"height": 640, "width": 640}) - >>> outputs = model(**inputs) + >>> with torch.no_grad(): + ... outputs = model(**inputs) >>> outputs.logits.shape torch.Size([1, 2]) ```"""