Create app.py
Browse files
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()
|