vtccvision commited on
Commit
e4b9ee5
β€’
1 Parent(s): a70acb7
Files changed (6) hide show
  1. .gitattributes +3 -8
  2. .gitignore +3 -0
  3. README.md +5 -5
  4. app.py +46 -0
  5. requirements-lock.txt +104 -0
  6. requirements.txt +4 -0
.gitattributes CHANGED
@@ -2,27 +2,20 @@
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
  *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
  *.ftz filter=lfs diff=lfs merge=lfs -text
7
  *.gz filter=lfs diff=lfs merge=lfs -text
8
  *.h5 filter=lfs diff=lfs merge=lfs -text
9
  *.joblib filter=lfs diff=lfs merge=lfs -text
10
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
  *.model filter=lfs diff=lfs merge=lfs -text
13
  *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
  *.onnx filter=lfs diff=lfs merge=lfs -text
17
  *.ot filter=lfs diff=lfs merge=lfs -text
18
  *.parquet filter=lfs diff=lfs merge=lfs -text
19
  *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
  *.pt filter=lfs diff=lfs merge=lfs -text
23
  *.pth filter=lfs diff=lfs merge=lfs -text
24
  *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
  *.tflite filter=lfs diff=lfs merge=lfs -text
@@ -30,5 +23,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
  *.wasm filter=lfs diff=lfs merge=lfs -text
31
  *.xz filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
- *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
  *.bz2 filter=lfs diff=lfs merge=lfs -text
 
5
  *.ftz filter=lfs diff=lfs merge=lfs -text
6
  *.gz filter=lfs diff=lfs merge=lfs -text
7
  *.h5 filter=lfs diff=lfs merge=lfs -text
8
  *.joblib filter=lfs diff=lfs merge=lfs -text
9
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
 
10
  *.model filter=lfs diff=lfs merge=lfs -text
11
  *.msgpack filter=lfs diff=lfs merge=lfs -text
 
 
12
  *.onnx filter=lfs diff=lfs merge=lfs -text
13
  *.ot filter=lfs diff=lfs merge=lfs -text
14
  *.parquet filter=lfs diff=lfs merge=lfs -text
15
  *.pb filter=lfs diff=lfs merge=lfs -text
 
 
16
  *.pt filter=lfs diff=lfs merge=lfs -text
17
  *.pth filter=lfs diff=lfs merge=lfs -text
18
  *.rar filter=lfs diff=lfs merge=lfs -text
 
19
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
  *.tar.* filter=lfs diff=lfs merge=lfs -text
21
  *.tflite filter=lfs diff=lfs merge=lfs -text
 
23
  *.wasm filter=lfs diff=lfs merge=lfs -text
24
  *.xz filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ sample_cord_receipt(receipt_00004).png filter=lfs diff=lfs merge=lfs -text
29
+ sample_image_cord_test_receipt_00004.png filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ env
2
+ __pycache__
3
+ *.png
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Cord V2
3
- emoji: 😻
4
- colorFrom: yellow
5
- colorTo: red
6
  sdk: gradio
7
- sdk_version: 3.27.0
8
  app_file: app.py
9
  pinned: false
10
  ---
 
1
  ---
2
+ title: Donut Base Finetuned Cord V2
3
+ emoji: 🍩
4
+ colorFrom: blue
5
+ colorTo: gray
6
  sdk: gradio
7
+ sdk_version: 3.0.26
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Donut
3
+ Copyright (c) 2022-present NAVER Corp.
4
+ MIT License
5
+
6
+ https://github.com/clovaai/donut
7
+ """
8
+ import gradio as gr
9
+ import torch
10
+ from PIL import Image
11
+
12
+ from donut import DonutModel
13
+
14
+ def demo_process(input_img):
15
+ global pretrained_model, task_prompt, task_name
16
+ # input_img = Image.fromarray(input_img)
17
+ output = pretrained_model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
18
+ return output
19
+
20
+ task_prompt = f"<s_cord-v2>"
21
+
22
+ image = Image.open("./sample_image_cord_test_receipt_00004.png")
23
+ image.save("cord_sample_receipt1.png")
24
+ image = Image.open("./sample_image_cord_test_receipt_00012.png")
25
+ image.save("cord_sample_receipt2.png")
26
+
27
+ pretrained_model = DonutModel.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
28
+ pretrained_model.eval()
29
+
30
+ demo = gr.Interface(
31
+ fn=demo_process,
32
+ inputs= gr.inputs.Image(type="pil"),
33
+ outputs="json",
34
+ title=f"Donut 🍩 demonstration for `cord-v2` task",
35
+ description="""This model is trained with 800 Indonesian receipt images of CORD dataset. <br>
36
+ Demonstrations for other types of documents/tasks are available at https://github.com/clovaai/donut <br>
37
+ More CORD receipt images are available at https://huggingface.co/datasets/naver-clova-ix/cord-v2
38
+
39
+ More details are available at:
40
+ - Paper: https://arxiv.org/abs/2111.15664
41
+ - GitHub: https://github.com/clovaai/donut""",
42
+ examples=[["cord_sample_receipt1.png"], ["cord_sample_receipt2.png"]],
43
+ cache_examples=False,
44
+ )
45
+
46
+ demo.launch(server_name="0.0.0.0")
requirements-lock.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.1.0
2
+ aiohttp==3.8.4
3
+ aiosignal==1.3.1
4
+ altair==4.2.2
5
+ anyio==3.6.2
6
+ async-timeout==4.0.2
7
+ attrs==23.1.0
8
+ certifi==2022.12.7
9
+ charset-normalizer==3.1.0
10
+ click==8.1.3
11
+ cmake==3.26.3
12
+ contourpy==1.0.7
13
+ cycler==0.11.0
14
+ datasets==2.11.0
15
+ dill==0.3.6
16
+ donut-python==1.0.9
17
+ entrypoints==0.4
18
+ fastapi==0.95.1
19
+ ffmpy==0.3.0
20
+ filelock==3.11.0
21
+ fonttools==4.39.3
22
+ frozenlist==1.3.3
23
+ fsspec==2023.4.0
24
+ gradio==3.27.0
25
+ gradio_client==0.1.3
26
+ h11==0.14.0
27
+ httpcore==0.17.0
28
+ httpx==0.24.0
29
+ huggingface-hub==0.13.4
30
+ idna==3.4
31
+ Jinja2==3.1.2
32
+ joblib==1.2.0
33
+ jsonschema==4.17.3
34
+ kiwisolver==1.4.4
35
+ lightning-utilities==0.8.0
36
+ linkify-it-py==2.0.0
37
+ lit==16.0.1
38
+ markdown-it-py==2.2.0
39
+ MarkupSafe==2.1.2
40
+ matplotlib==3.7.1
41
+ mdit-py-plugins==0.3.3
42
+ mdurl==0.1.2
43
+ mpmath==1.3.0
44
+ multidict==6.0.4
45
+ multiprocess==0.70.14
46
+ munch==2.5.0
47
+ networkx==3.1
48
+ nltk==3.8.1
49
+ numpy==1.24.2
50
+ nvidia-cublas-cu11==11.10.3.66
51
+ nvidia-cuda-cupti-cu11==11.7.101
52
+ nvidia-cuda-nvrtc-cu11==11.7.99
53
+ nvidia-cuda-runtime-cu11==11.7.99
54
+ nvidia-cudnn-cu11==8.5.0.96
55
+ nvidia-cufft-cu11==10.9.0.58
56
+ nvidia-curand-cu11==10.2.10.91
57
+ nvidia-cusolver-cu11==11.4.0.1
58
+ nvidia-cusparse-cu11==11.7.4.91
59
+ nvidia-nccl-cu11==2.14.3
60
+ nvidia-nvtx-cu11==11.7.91
61
+ orjson==3.8.10
62
+ packaging==23.1
63
+ pandas==2.0.0
64
+ Pillow==9.5.0
65
+ pyarrow==11.0.0
66
+ pydantic==1.10.7
67
+ pydub==0.25.1
68
+ pyparsing==3.0.9
69
+ pyrsistent==0.19.3
70
+ python-dateutil==2.8.2
71
+ python-multipart==0.0.6
72
+ pytorch-lightning==2.0.1.post0
73
+ pytz==2023.3
74
+ PyYAML==6.0
75
+ regex==2023.3.23
76
+ requests==2.28.2
77
+ responses==0.18.0
78
+ ruamel.yaml==0.17.21
79
+ ruamel.yaml.clib==0.2.7
80
+ sconf==0.2.5
81
+ semantic-version==2.10.0
82
+ sentencepiece==0.1.98
83
+ six==1.16.0
84
+ sniffio==1.3.0
85
+ starlette==0.26.1
86
+ sympy==1.11.1
87
+ timm==0.6.13
88
+ tokenizers==0.13.3
89
+ toolz==0.12.0
90
+ torch==2.0.0
91
+ torchmetrics==0.11.4
92
+ torchvision==0.15.1
93
+ tqdm==4.65.0
94
+ transformers==4.24.0
95
+ triton==2.0.0
96
+ typing_extensions==4.5.0
97
+ tzdata==2023.3
98
+ uc-micro-py==1.0.1
99
+ urllib3==1.26.15
100
+ uvicorn==0.21.1
101
+ websockets==11.0.2
102
+ xxhash==3.2.0
103
+ yarl==1.8.2
104
+ zss==1.2.0
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ donut-python
3
+ gradio
4
+ transformers==4.24.0