clovaai / donut

Official Implementation of OCR-free Document Understanding Transformer (Donut) and Synthetic Document Generator (SynthDoG), ECCV 2022
https://arxiv.org/abs/2111.15664
MIT License
5.53k stars 444 forks source link

make sure `_init_weights` is implemented for <class 'donut.model.DonutModel'> #243

Open asfansajid123 opened 10 months ago

asfansajid123 commented 10 months ago

@gwkrsrch

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 you elaborate why this error is persisting or what could have gotten wrong in cloning the official branch? Your input would really mean a lot. image

Never-up commented 10 months ago

@asfansajid123 hello ,Has the problem been solved?i`m same problem

Codedrainer commented 9 months ago

Hey @asfansajid123 and @gwkrsrch do you guys found any solution for this. Its been days since i am struggling with this problem.

ariefwijaya commented 9 months ago

same problem when using latest transformers version

crackthedata commented 8 months ago

Running into the same problem here. After retraining on local data and pushing model to Hugging Face, I'm getting this error when pulling it down again for inference. Also, I'm using timm==0.5.4 and transformers==4.25.1, as the latest versions of these packages were throwing errors as well.

Any update here would be most helpful.

Codedrainer commented 8 months ago

@crackthedata use this to install donut-python

pip install git+https://github.com/clovaai/donut.git

crackthedata commented 8 months ago

@Codedrainer Yes, that is how I was able to run train.py locally. After training for 30 epochs using images stored locally, I pushed the model in the result directory to Hugging Face to https://huggingface.co/Crackingallthedatas/cord-tuned/tree/official so I can use it later.

When I run model = DonutModel.from_pretrained("Crackingallthedatas/cord-tuned") , I get the above error. I'm using naver-clova-ix/donut-base as the base model that train.py pulls from. It seems that train.py does not output the initial weights present in naver-clova-ix/donut-base once the training completes.

afreestudy commented 7 months ago

same problem.how can i solve this?

bugface commented 6 months ago

it seems that HF have some modification on the model, if you want to avoid the error use the model that is official release such as https://huggingface.co/naver-clova-ix/donut-base/tree/official.

The main branch of the model on HF model repo is from HF modification version which will cause problem but if you use the one from official branch, then the problem will be solved.