Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import os
|
3 |
import argparse
|
4 |
import torch
|
@@ -6,12 +7,11 @@ from PIL import Image
|
|
6 |
from pdf2image import convert_from_path
|
7 |
from donut import DonutModel
|
8 |
|
9 |
-
def demo_process(
|
10 |
global model, task_prompt, task_name
|
11 |
-
|
12 |
-
input_img_list = convert_from_path(full_path)
|
13 |
# output = model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
|
14 |
-
return
|
15 |
|
16 |
parser = argparse.ArgumentParser()
|
17 |
parser.add_argument("--task", type=str, default="SGSInvoice")
|
@@ -22,5 +22,5 @@ task_prompt = f"<s_{task_name}>"
|
|
22 |
|
23 |
# model = DonutModel.from_pretrained("uartimcs/donut-invoice-extract")
|
24 |
# model.eval()
|
25 |
-
demo = gr.Interface(fn=demo_process,inputs=
|
26 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from gradio_pdf import PDF
|
3 |
import os
|
4 |
import argparse
|
5 |
import torch
|
|
|
7 |
from pdf2image import convert_from_path
|
8 |
from donut import DonutModel
|
9 |
|
10 |
+
def demo_process(doc):
|
11 |
global model, task_prompt, task_name
|
12 |
+
img = convert_from_path(doc)[0]
|
|
|
13 |
# output = model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
|
14 |
+
return doc
|
15 |
|
16 |
parser = argparse.ArgumentParser()
|
17 |
parser.add_argument("--task", type=str, default="SGSInvoice")
|
|
|
22 |
|
23 |
# model = DonutModel.from_pretrained("uartimcs/donut-invoice-extract")
|
24 |
# model.eval()
|
25 |
+
demo = gr.Interface(fn=demo_process,inputs=PDF(label="Upload PDF"),outputs="text", title=f"Donut 🍩 demonstration for `{task_name}` task",)
|
26 |
demo.launch()
|