Spaces:
Sleeping
Sleeping
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() | |