Views
No views yet
1from transformers import pipeline
2
3nlp = pipeline(
4 "document-question-answering",
5 model="impira/layoutlm-document-qa",
6)
7
8nlp(
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
14nlp(
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
20nlp(
21 "https://www.accountingcoach.com/wp-content/uploads/2013/10/income-statement-example@2x.png",
22 "What are the 2020 net sales?"
23)
24# {'score': 0.59147286, 'answer': '$ 3,750', 'start': 19, 'end': 20}pip install git+https://github.com/huggingface/transformers.git@2ef774211733f0acf8d3415f9284c49ef219e991