Spaces:
Sleeping
Sleeping
File size: 968 Bytes
b719e63 583d619 b719e63 9414621 b719e63 9414621 b719e63 f70b02d f376ec4 e38c200 f70b02d f06ba45 b719e63 80b787f e38c200 b719e63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
import os
import argparse
import torch
from PIL import Image
from pdf2image import convert_from_path
from donut import DonutModel
def demo_process(pdf_path):
global model, task_prompt, task_name
full_path = os.path.join(os.getcwd(),pdf_path)
input_img_list = convert_from_path(full_path)
# output = model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
return full_path
parser = argparse.ArgumentParser()
parser.add_argument("--task", type=str, default="SGSInvoice")
parser.add_argument("--pretrained_path", type=str, default="uartimcs/donut-invoice-extract")
args, left_argv = parser.parse_known_args()
task_name = args.task
task_prompt = f"<s_{task_name}>"
# model = DonutModel.from_pretrained("uartimcs/donut-invoice-extract")
# model.eval()
demo = gr.Interface(fn=demo_process,inputs=gr.File(label="Upload PDF"),outputs="text", title=f"Donut 🍩 demonstration for `{task_name}` task",)
demo.launch() |