TeddyChan commited on
Commit
b5201d3
·
1 Parent(s): c62d492
Files changed (5) hide show
  1. .gitignore +1 -0
  2. app.py +35 -0
  3. inv17.jpg +0 -0
  4. inv87.jpg +0 -0
  5. requirements.txt +6 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .venv/
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from PIL import Image
4
+
5
+ from donut import DonutModel
6
+
7
+ def demo_process(input_img):
8
+ global pretrained_model, task_prompt, task_name
9
+ # input_img = Image.fromarray(input_img)
10
+ output = pretrained_model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
11
+ return output
12
+ task_name = "preparedFinetuneData_Bird"
13
+ # task_name = "cord-v2"
14
+ task_prompt = f"<s_{task_name}>"
15
+
16
+ image = Image.open("inv87.jpg")
17
+ image.save("inv87.jpg")
18
+ image = Image.open("inv17.jpg")
19
+ image.save("inv17.jpg")
20
+
21
+ # PATH = 'epochs30_base_on_donut_base/'
22
+ pretrained_model = DonutModel.from_pretrained("Goodarc/teddydountmodel1")
23
+ pretrained_model.eval()
24
+
25
+ demo = gr.Interface(
26
+ fn=demo_process,
27
+ inputs= gr.Image(type="pil"),
28
+ outputs="json",
29
+ title=f"Goodarc p9 for `{task_name}` task, epochs30",
30
+ description="""Goodarc teddy dount model1 訓練.
31
+ """,
32
+ examples=[["inv87.jpg"], ["inv17.jpg"]],
33
+ cache_examples=False,
34
+ )
35
+ demo.launch()
inv17.jpg ADDED
inv87.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ torch
2
+ donut-python
3
+ gradio
4
+ transformers==4.25.1
5
+ timm==0.5.4
6
+ pytorch-lightning==1.6.4