Joyantac33 commited on
Commit
14760ee
·
1 Parent(s): 1973c2f

Upload 6 files

Browse files
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* 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
 
 
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
35
+ sample_image_cord_test_receipt_00004.png filter=lfs diff=lfs merge=lfs -text
000.jpg ADDED
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()
data_sample.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ donut-python
3
+ gradio
4
+ transformers==4.24.0
sample_image_cord_test_receipt_00004.png ADDED

Git LFS Details

  • SHA256: 8f3eee7068c96e86cdb2e4b5c53085cb5e1439462edd55c373548cb1962801ad
  • Pointer size: 132 Bytes
  • Size of remote file: 1.64 MB
sample_image_cord_test_receipt_00012.png ADDED