Instructions to use naver-clova-ix/donut-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use naver-clova-ix/donut-base with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="naver-clova-ix/donut-base")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("naver-clova-ix/donut-base") model = AutoModelForMultimodalLM.from_pretrained("naver-clova-ix/donut-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add HuggingFace files
This PR adds the HuggingFace compatible files for Donut to work with the VisionEncoderDecoder model class.
Going to merge this, as the Donut PyPi package is already using the "official" branch.
@nielsr Can you please explain how you make the model compatible with the VisionEncoderDecoder? Is there a recipe for it?
I'm asking this because after fine-tuning the model using donut-python we get a model similar to the official branch of donut. But the official model is not compatible with ONNX.
The only donut models that I can convert to valid ONNX models are main branch models (your commit) which are compatible with VisionEncoderDecoder.
Hi,
If you'd like to convert the model from the original implementation to the HF format (i.e. the VisionEncoderDecoderclass), you can use this conversion script: https://github.com/huggingface/transformers/blob/main/src/transformers/models/donut/convert_donut_to_pytorch.py.
Note that you may need to tweak it a bit to make sure it can convert your custom checkpoint, but should run fine