sdripie commited on
Commit
59737d6
·
1 Parent(s): 0a302b8

sample site

Browse files
Files changed (2) hide show
  1. app.py +28 -2
  2. requirements.txt +3 -0
app.py CHANGED
@@ -1,8 +1,34 @@
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
5
 
 
 
 
 
 
 
 
6
 
 
 
 
 
7
 
 
 
8
 
 
 
 
 
 
 
1
+ import warnings
2
+ warnings.filterwarnings("ignore", category=UserWarning, module="torchvision")
3
+ warnings.filterwarnings("ignore", category=FutureWarning, module="transformers")
4
+ warnings.filterwarnings("ignore")
5
+
6
+
7
+ from transformers import pipeline
8
+ import pandas as pd
9
  import streamlit as st
10
 
11
+ # Initialize the pipeline
12
+ pipe = pipeline("table-question-answering", model="google/tapas-large-finetuned-wtq")
13
 
14
+ # Define the table data
15
+ data = {
16
+ "year": [1896, 1900, 1904, 2004, 2008, 2012],
17
+ "city": ["athens", "paris", "st. louis", "athens", "beijing", "london"]
18
+ }
19
+ table = pd.DataFrame(data)
20
+ table = table.astype(str) # Ensure all values are strings
21
 
22
+ # Streamlit app layout
23
+ st.title("Table Question Answering")
24
+ st.write("### Input Table")
25
+ st.dataframe(table)
26
 
27
+ # User query
28
+ query = st.text_input("Ask a question about the table:", "In which year did beijing host the Olympic Games?")
29
 
30
+ # Process query and display result
31
+ if st.button("Get Answer"):
32
+ result = pipe(table=table, query=query)
33
+ st.write("### Answer")
34
+ st.write(result["answer"])
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit==1.41.1
2
+ torch
3
+ transformers