philschmid / donut-base-finetuned-cord-v2

huggingface.co
Total runs: 42
24-hour runs: 1
7-day runs: 12
30-day runs: 17
Model's Last Updated: October 18 2022
image-to-text

Introduction of donut-base-finetuned-cord-v2

Model Details of donut-base-finetuned-cord-v2

Fork of naver-clova-ix/donut-base-finetuned-cord-v2

This is fork of naver-clova-ix/donut-base-finetuned-cord-v2 implementing a custom handler.py as an example for how to use donut models with inference-endpoints


Donut (base-sized model, fine-tuned on CORD)

Donut model fine-tuned on CORD. It was introduced in the paper OCR-free Document Understanding Transformer by Geewok et al. and first released in this repository .

Donut consists of a vision encoder (Swin Transformer) and a text decoder (BART). Given an image, the encoder first encodes the image into a tensor of embeddings (of shape batch_size, seq_len, hidden_size), after which the decoder autoregressively generates text, conditioned on the encoding of the encoder.

Use with Inference Endpoints

Hugging Face Inference endpoints can directly work with binary data, this means that we can directly send our image from our document to the endpoint. We are going to use requests to send our requests. (make your you have it installed pip install requests )

result

Send requests with Pyton

load sample image

wget https://huggingface.co/philschmid/donut-base-finetuned-cord-v2/resolve/main/sample.png

send request to endpoint

import json
import requests as r
import mimetypes

ENDPOINT_URL="" # url of your endpoint
HF_TOKEN="" # organization token where you deployed your endpoint

def predict(path_to_image:str=None):
    with open(path_to_image, "rb") as i:
      b = i.read()
    headers= {
        "Authorization": f"Bearer {HF_TOKEN}",
        "Content-Type": mimetypes.guess_type(path_to_image)[0]
    }
    response = r.post(ENDPOINT_URL, headers=headers, data=b)
    return response.json()

prediction = predict(path_to_image="sample.png")

print(prediction)
# {'menu': [{'nm': '0571-1854 BLUS WANITA',
#   'unitprice': '@120.000',
#   'cnt': '1',
#   'price': '120,000'},
#  {'nm': '1002-0060 SHOPPING BAG', 'cnt': '1', 'price': '0'}],
# 'total': {'total_price': '120,000',
#  'changeprice': '0',
#  'creditcardprice': '120,000',
#  'menuqty_cnt': '1'}}

curl example

curl https://ak7gduay2ypyr9vp.us-east-1.aws.endpoints.huggingface.cloud \
-X POST \
--data-binary 'sample.png' \
-H "Authorization: Bearer XXX" \
-H "Content-Type: null"

Runs of philschmid donut-base-finetuned-cord-v2 on huggingface.co

42
Total runs
1
24-hour runs
5
3-day runs
12
7-day runs
17
30-day runs

More Information About donut-base-finetuned-cord-v2 huggingface.co Model

More donut-base-finetuned-cord-v2 license Visit here:

https://choosealicense.com/licenses/mit

donut-base-finetuned-cord-v2 huggingface.co

donut-base-finetuned-cord-v2 huggingface.co is an AI model on huggingface.co that provides donut-base-finetuned-cord-v2's model effect (), which can be used instantly with this philschmid donut-base-finetuned-cord-v2 model. huggingface.co supports a free trial of the donut-base-finetuned-cord-v2 model, and also provides paid use of the donut-base-finetuned-cord-v2. Support call donut-base-finetuned-cord-v2 model through api, including Node.js, Python, http.

donut-base-finetuned-cord-v2 huggingface.co Url

https://huggingface.co/philschmid/donut-base-finetuned-cord-v2

philschmid donut-base-finetuned-cord-v2 online free

donut-base-finetuned-cord-v2 huggingface.co is an online trial and call api platform, which integrates donut-base-finetuned-cord-v2's modeling effects, including api services, and provides a free online trial of donut-base-finetuned-cord-v2, you can try donut-base-finetuned-cord-v2 online for free by clicking the link below.

philschmid donut-base-finetuned-cord-v2 online free url in huggingface.co:

https://huggingface.co/philschmid/donut-base-finetuned-cord-v2

donut-base-finetuned-cord-v2 install

donut-base-finetuned-cord-v2 is an open source model from GitHub that offers a free installation service, and any user can find donut-base-finetuned-cord-v2 on GitHub to install. At the same time, huggingface.co provides the effect of donut-base-finetuned-cord-v2 install, users can directly use donut-base-finetuned-cord-v2 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

donut-base-finetuned-cord-v2 install url in huggingface.co:

https://huggingface.co/philschmid/donut-base-finetuned-cord-v2

Url of donut-base-finetuned-cord-v2

donut-base-finetuned-cord-v2 huggingface.co Url

Provider of donut-base-finetuned-cord-v2 huggingface.co

philschmid
ORGANIZATIONS

Other API from philschmid