Tabular_Rasa / app.py
jethrovic's picture
Create app.py
ba79e6e
raw
history blame
1.02 kB
import streamlit as st
import pandas as pd
from transformers import pipeline
# Initialize the table-question-answering pipeline
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
# Streamlit app
st.title("Table Question Answering")
# File uploader for table data
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
# Text input for question
question = st.text_input("Enter your question:")
# Process table and question
if uploaded_file is not None and question:
# Read table from CSV
table = pd.read_csv(uploaded_file)
# Display the table
st.write("Uploaded Table:")
st.write(table)
# Get answer
answer = tqa(table=table, query=question)['cells'][0]
# Display the answer
st.write("Answer:", answer)
# Instructions
st.markdown("""
*First, upload a CSV file containing your table data. The CSV should have headers for each column.*
*Then, enter a question related to the table and press Enter to see the answer.*
""")