ValueError: The following `model_kwargs` are not used by the model: ['encoder_outputs'] (note: typos in the generate arguments will also show up

Viewed 235

When I try to run my code for Donut for DocVQA model, I got the following error

"""Test"""
from donut import DonutModel
from PIL import Image
import torch

model = DonutModel.from_pretrained(
    "naver-clova-ix/donut-base-finetuned-cord-v2")
if torch.cuda.is_available():
    model.half()
    device = torch.device("cuda")
    model.to(device)
else:
    model.encoder.to(torch.bfloat16)
model.eval()
image = Image.open(
    "./src/png-report-page_capone_v1_August_2017_GMS_Balance_Sheet_0.png").convert("RGB")
output = model.inference(image=image, prompt="<s_cord-v2>")

print(output)

The error`

ValueError: The following `model_kwargs` are not used by the model: ['encoder_outputs'] (note: typos in the generate arguments will also show up in this list)
1 Answers

Check the transformers library version. For me, I reinstalled the 4.21.3 version and it worked.

Related