Spaces:
Sleeping
Sleeping
File size: 1,320 Bytes
44d3673 853806d 44d3673 853806d 44d3673 dfda771 853806d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import streamlit as st
import re
from transformers import pipeline
st.title("Docs Answering AI App")
st.write("---")
st.write("### Give Doc Receipt Images to the AI and ask it whats on the receipt.")
st.warning("**Powered by AI Language Models...**")
st.write("---")
import streamlit as st
import pandas as pd
from io import StringIO
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
# To read file as bytes:
bytes_data = uploaded_file.getvalue()
st.write(bytes_data)
# To convert to a string based IO:
stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
st.write(stringio)
# To read file as string:
string_data = stringio.read()
st.write(string_data)
# Can be used wherever a "file-like" object is accepted:
dataframe = pd.read_csv(uploaded_file)
st.write(dataframe)
nlp = pipeline(
"document-question-answering",
model="impira/layoutlm-document-qa",
)
res = nlp(
"https://templates.invoicehome.com/invoice-template-us-neat-750px.png",
"What is the invoice number?"
)
st.write(res['answer'])
# {'score': 0.9943977, 'answer': 'us-001', 'start': 15, 'end': 15}
res = nlp(
"https://miro.medium.com/max/787/1*iECQRIiOGTmEFLdWkVIH2g.jpeg",
"What is the purchase amount?"
)
st.write(res['answer']) |