jethrovic commited on
Commit
ba79e6e
·
1 Parent(s): 4dd5ff7

Create app.py

Browse files

Initial write up

Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from transformers import pipeline
4
+
5
+ # Initialize the table-question-answering pipeline
6
+ tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
7
+
8
+ # Streamlit app
9
+ st.title("Table Question Answering")
10
+
11
+ # File uploader for table data
12
+ uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
13
+
14
+ # Text input for question
15
+ question = st.text_input("Enter your question:")
16
+
17
+ # Process table and question
18
+ if uploaded_file is not None and question:
19
+ # Read table from CSV
20
+ table = pd.read_csv(uploaded_file)
21
+
22
+ # Display the table
23
+ st.write("Uploaded Table:")
24
+ st.write(table)
25
+
26
+ # Get answer
27
+ answer = tqa(table=table, query=question)['cells'][0]
28
+
29
+ # Display the answer
30
+ st.write("Answer:", answer)
31
+
32
+ # Instructions
33
+ st.markdown("""
34
+ *First, upload a CSV file containing your table data. The CSV should have headers for each column.*
35
+ *Then, enter a question related to the table and press Enter to see the answer.*
36
+ """)