Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,10 +8,12 @@ from donut import DonutModel
|
|
8 |
|
9 |
def demo_process(pdf_path):
|
10 |
global model, task_prompt, task_name
|
11 |
-
|
12 |
-
input_img =
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
parser = argparse.ArgumentParser()
|
16 |
parser.add_argument("--task", type=str, default="SGSInvoice")
|
17 |
parser.add_argument("--pretrained_path", type=str, default="uartimcs/donut-invoice-extract")
|
@@ -21,5 +23,5 @@ task_prompt = f"<s_{task_name}>"
|
|
21 |
|
22 |
model = DonutModel.from_pretrained("uartimcs/donut-invoice-extract")
|
23 |
model.eval()
|
24 |
-
demo = gr.Interface(fn=demo_process,inputs=gr.File(label="Upload PDF"),outputs="
|
25 |
demo.launch()
|
|
|
8 |
|
9 |
def demo_process(pdf_path):
|
10 |
global model, task_prompt, task_name
|
11 |
+
return pdf_path.name
|
12 |
+
# input_img = convert_from_path(pdf_path.name)
|
13 |
+
# input_img = Image.fromarray(input_img)
|
14 |
+
# output = model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
|
15 |
+
# return output
|
16 |
+
|
17 |
parser = argparse.ArgumentParser()
|
18 |
parser.add_argument("--task", type=str, default="SGSInvoice")
|
19 |
parser.add_argument("--pretrained_path", type=str, default="uartimcs/donut-invoice-extract")
|
|
|
23 |
|
24 |
model = DonutModel.from_pretrained("uartimcs/donut-invoice-extract")
|
25 |
model.eval()
|
26 |
+
demo = gr.Interface(fn=demo_process,inputs=gr.File(label="Upload PDF"),outputs="text", title=f"Donut 🍩 demonstration for `{task_name}` task",)
|
27 |
demo.launch()
|