abidlabs HF staff commited on
Commit
2a2bd59
1 Parent(s): d180623

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ nlp = pipeline(
5
+ "document-question-answering",
6
+ model="impira/layoutlm-document-qa",
7
+ )
8
+
9
+ def predict(img, text):
10
+ return nlp(
11
+ img,
12
+ text
13
+ )['answer']
14
+
15
+ gr.Interface(predict, [gr.Image(type="filepath"), gr.Textbox(label="Question")], gr.Textbox()).launch()