Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,22 +15,29 @@ pipe_tapex = pipeline(
|
|
15 |
"table-question-answering", model=model_tapex, tokenizer=tokenizer_tapex
|
16 |
)
|
17 |
|
18 |
-
model_tapas = "google/tapas-large-finetuned-wtq"
|
19 |
-
tokenizer_tapas = AutoTokenizer.from_pretrained(model_tapas)
|
20 |
-
model_tapas = AutoModelForTableQuestionAnswering.from_pretrained(model_tapas)
|
21 |
-
pipe_tapas = pipeline(
|
22 |
-
|
23 |
-
)
|
24 |
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
table =
|
30 |
result_tapex = pipe_tapex(table=table, query=query)
|
31 |
-
result_tapas = pipe_tapas(table=table, query=query)
|
32 |
return result_tapex["answer"], result_tapas["answer"], correct_answer
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# Inputs
|
36 |
query_text = gr.Text(label="Enter a question")
|
|
|
15 |
"table-question-answering", model=model_tapex, tokenizer=tokenizer_tapex
|
16 |
)
|
17 |
|
18 |
+
# model_tapas = "google/tapas-large-finetuned-wtq"
|
19 |
+
# tokenizer_tapas = AutoTokenizer.from_pretrained(model_tapas)
|
20 |
+
# model_tapas = AutoModelForTableQuestionAnswering.from_pretrained(model_tapas)
|
21 |
+
# pipe_tapas = pipeline(
|
22 |
+
# "table-question-answering", model=model_tapas, tokenizer=tokenizer_tapas
|
23 |
+
# )
|
24 |
|
25 |
+
#new
|
26 |
+
pipe_tapas = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
27 |
|
28 |
+
|
29 |
+
def process(query, file, correct_answer, rows=20):
|
30 |
+
table = pd.read_csv(file.name, header=0).astype(str)
|
31 |
+
table = table[:rows]
|
32 |
result_tapex = pipe_tapex(table=table, query=query)
|
|
|
33 |
return result_tapex["answer"], result_tapas["answer"], correct_answer
|
34 |
|
35 |
+
def process2(query, csv_data):
|
36 |
+
table = pd.DataFrame.from_dict(csv_data)
|
37 |
+
# result_tapex = pipe_tapex(table=table, query=query)
|
38 |
+
result_tapas = pipe_tapas(table=table, query=query)['cells'][0]
|
39 |
+
return "", result_tapas, correct_answer
|
40 |
+
|
41 |
|
42 |
# Inputs
|
43 |
query_text = gr.Text(label="Enter a question")
|