ignaciaginting commited on
Commit
8bc3f30
·
verified ·
1 Parent(s): 29bae75

create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ nlp = pipeline(
4
+ "document-question-answering",
5
+ model="impira/layoutlm-document-qa",
6
+ )
7
+
8
+ nlp(
9
+ "https://templates.invoicehome.com/invoice-template-us-neat-750px.png",
10
+ "What is the invoice number?"
11
+ )
12
+ # {'score': 0.9943977, 'answer': 'us-001', 'start': 15, 'end': 15}
13
+
14
+ nlp(
15
+ "https://miro.medium.com/max/787/1*iECQRIiOGTmEFLdWkVIH2g.jpeg",
16
+ "What is the purchase amount?"
17
+ )
18
+ # {'score': 0.9912159, 'answer': '$1,000,000,000', 'start': 97, 'end': 97}
19
+
20
+ nlp(
21
+ "https://www.accountingcoach.com/wp-content/uploads/2013/10/[email protected]",
22
+ "What are the 2020 net sales?"
23
+ )
24
+ # {'score': 0.59147286, 'answer': '$ 3,750', 'start': 19, 'end': 20}