Downloads · 30 days
0
philschmid/space-naver-donut-cord
space-naver-donut-cord is a machine learning model from philschmid. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for generic.
This is a fork of the naver-clova-ix/donut-base-finetuned-cord-v2 Space.
Downloads · 30 days
0
Access
Public
Updated Aug 11, 2022
Repo size
—
Likes
3
Public
Click a slice to open those files.
.png36.3 KB · 89%
From the Hugging Face model README
_This is a fork of the naver-clova-ix/donut-base-finetuned-cord-v2 Space.
This repository implements a custom container for 🤗 Inference Endpoints using a Gradio space.
To deploy this model as an Inference Endpoint, you have to select Custom as task and a custom image.
philschmi/gradio-api:cpuphilschmi/gradio-api:gpu7860/Also make sure to add server_name="0.0.0.0" in your launch() call to make sure the request is correct proxied.
If you want to use the UI with the Inference Endpoint, you have to select as endpoint type public and add auth through gradio
Get an image you want to use, e.g.
!wget https://datasets-server.huggingface.co/assets/naver-clova-ix/cord-v2/--/naver-clova-ix--cord-v2/train/0/image/image.jpg
run inference
import requests as r
import base64
ENDPOINT_URL = ""
HF_TOKEN = ""
def predict(path_to_image: str = None):
ext = path_to_image.split('.')[-1]
prefix = f'data:image/{ext};base64,'
with open(path_to_image, 'rb') as f:
img = f.read()
payload = {"data": [prefix + base64.b64encode(img).decode('utf-8')]}
response = r.post(
f"{ENDPOINT_URL}/api/predict", headers={"Authorization": f"Bearer {HF_TOKEN}"}, json=payload
)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Error: {response.status_code}")
prediction = predict(path_to_image="image.jpg")