Make sure _init_weights is implemented for <class 'donut.model.DonutModel'>

197 Views Asked by At

I am facing an issue with the donut repo. I am trying to load the pretrained model naver-clova-ix/donut-base-finetuned-cord-v2 but getting the same error every time:

Make sure _init_weights is implemented for <class 'donut.model.DonutModel'>

P.s: I have already tried by cloning the official branch of the repo via huggingface.co

Can anyone elaborate why this error is persisting or what could have gotten wrong in cloning the official branch? Suggestions will be appreciated

enter image description here

    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("train/images/0000ae6cbdb1.jpg").convert("RGB")
output = model.inference(image=image, prompt="<s_sroie-donut>")
output
0

There are 0 best solutions below