File size: 643 Bytes
ce7fb65
 
 
cd7ec0d
 
ce7fb65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
from transformers import pipeline
from PIL import Image
import os
os.system("python3 -m pip install transformers")
nlp = pipeline(
    "document-question-answering",
    model="impira/layoutlm-document-qa",
)
st.title("DocVPA Demo")

file_name = st.file_uploader("Upload a document/image(.pdf, .png, .jpeg, .jpg)")

question = st.text_input("Write your question regarding to your document")

if file_name is not None:
    col1, col2 = st.columns(2)

    image = Image.open(file_name)
    col1.image(image, use_column_width=True)
    
if st.button("Send"):
    predictions = nlp(image, question)
    st.write(predictions)