File size: 728 Bytes
14b4ece
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
import gradio as gr

from transformers import pipeline
from PIL import Image

model = "pacman2223/test-mod"

image = Image.open("./sample_cv.png")
image.save("cv.png")
image = Image.open("./sample_hack.png")
image.save("hack.png")

def demo_process(img, question):

    qa_pipeline = pipeline("document-question-answering", model=model)
    qa_pipeline(img, question)

    return qa_pipeline["answer"]


demo = gr.Interface(
    fn=demo_process,
    inputs=["image", "text"],
    outputs="json",
    title=f"BIP demonstration for `layoutlmv2` task",
    description="""This model is trained with 1200 receipt images of Docqva dataset. <br>""",
    examples=[["cv.png"], ["hack.png"]],
    cache_examples=False,
)

demo.launch()