File size: 610 Bytes
b719e63
5579dac
 
 
4eeed0b
0cf4942
5579dac
c6e80d0
5579dac
5a10adf
b719e63
587a4f8
 
5579dac
 
8df8cf7
0cf4942
5579dac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
import argparse
import torch
from donut import DonutModel
from pdf2image import convert_from_path

def demo_process(pdf_file):
    # images = convert_from_path(pdf_file)    
    # output = model.inference(image=input_img, prompt=task_prompt)["predictions"][0]
    return pdf_file.name

# model = DonutModel.from_pretrained("uartimcs/donut-invoice-extract")
# model.eval()
task_name = "SGSInvoice"
task_prompt = f"<s_{task_name}>"

demo = gr.Interface(fn=demo_process,inputs=gr.File(label="Upload PDF"),outputs="text", title=f"Donut 🍩 demonstration for `{task_name}` task",)
demo.launch()