From ed36fefed0fe235ce9a386fc3ee1a748f41c518a Mon Sep 17 00:00:00 2001 From: Jade Choghari Date: Sat, 21 Dec 2024 16:25:51 +0300 Subject: [PATCH] Update src/transformers/models/textnet/modeling_textnet.py Co-authored-by: Pavel Iakubovskii --- src/transformers/models/textnet/modeling_textnet.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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]) ```"""