thinkersloop commited on
Commit
5139134
1 Parent(s): 78db208

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -21
app.py CHANGED
@@ -1,10 +1,3 @@
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
@@ -19,12 +12,12 @@ def demo_process(input_img):
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.encoder.to(torch.bfloat16)
29
  pretrained_model.eval()
30
 
@@ -32,15 +25,9 @@ demo = gr.Interface(
32
  fn=demo_process,
33
  inputs= gr.inputs.Image(type="pil"),
34
  outputs="json",
35
- title=f"Donut 🍩 demonstration for `cord-v2` task",
36
- description="""This model is trained with 800 Indonesian receipt images of CORD dataset. <br>
37
- Demonstrations for other types of documents/tasks are available at https://github.com/clovaai/donut <br>
38
- More CORD receipt images are available at https://huggingface.co/datasets/naver-clova-ix/cord-v2
39
-
40
- More details are available at:
41
- - Paper: https://arxiv.org/abs/2111.15664
42
- - GitHub: https://github.com/clovaai/donut""",
43
- examples=[["cord_sample_receipt1.png"], ["cord_sample_receipt2.png"]],
44
  cache_examples=False,
45
  )
46
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import torch
3
  from PIL import Image
 
12
 
13
  task_prompt = f"<s_cord-v2>"
14
 
15
+ image = Image.open("./sample_1.jpg")
16
+ image.save("cord_sample_1.png")
17
+ image = Image.open("./sample_2.jpg")
18
+ image.save("cord_sample_2.png")
19
 
20
+ pretrained_model = DonutModel.from_pretrained("thinkersloop/donut-demo")
21
  pretrained_model.encoder.to(torch.bfloat16)
22
  pretrained_model.eval()
23
 
 
25
  fn=demo_process,
26
  inputs= gr.inputs.Image(type="pil"),
27
  outputs="json",
28
+ title=f"Transformers demo for `cord-v2` task",
29
+ description="""This model is trained with 30 driver's license images of CORD dataset. <br>""",
30
+ examples=[["cord_sample_1.png"], ["cord_sample_2.png"]],
 
 
 
 
 
 
31
  cache_examples=False,
32
  )
33