aaravlovescodes commited on
Commit
ce7fb65
1 Parent(s): 2adbc8f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ nlp = pipeline(
6
+ "document-question-answering",
7
+ model="impira/layoutlm-document-qa",
8
+ )
9
+ st.title("DocVPA Demo")
10
+
11
+ file_name = st.file_uploader("Upload a document/image(.pdf, .png, .jpeg, .jpg)")
12
+
13
+ question = st.text_input("Write your question regarding to your document")
14
+
15
+ if file_name is not None:
16
+ col1, col2 = st.columns(2)
17
+
18
+ image = Image.open(file_name)
19
+ col1.image(image, use_column_width=True)
20
+
21
+ if st.button("Send"):
22
+ predictions = nlp(image, question)
23
+ st.write(predictions)