Spaces:
Build error
Build error
Commit
•
b7ede78
1
Parent(s):
ccaad04
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import library
|
2 |
+
import warnings
|
3 |
+
warnings.filterwarnings("ignore")
|
4 |
+
import torch
|
5 |
+
import pandas as pd # pandas for datafrang
|
6 |
+
|
7 |
+
# we import pipeline using transfromer library
|
8 |
+
from transformers import pipeline
|
9 |
+
|
10 |
+
|
11 |
+
# we creates a pipeline specifically designed for answering questions based on a table using a pre-trained model.
|
12 |
+
pipe = pipeline(task="table-question-answering",model="google/tapas-base-finetuned-wtq")
|
13 |
+
|
14 |
+
#uploading csv
|
15 |
+
table=pd.read_csv(input("input the CSV file link: "))
|
16 |
+
|
17 |
+
# converts the data types of all elements in a pandas DataFrame (table) to strings
|
18 |
+
table = table.astype(str)
|
19 |
+
table
|
20 |
+
|
21 |
+
#The code you provided combines user input and table-based question answering
|
22 |
+
query=input("type the Question: ")
|
23 |
+
print(pipe(table=table,query=query)["answer"])
|