Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import torch
|
| 4 |
-
from transformers import TapasConfig, TapasForQuestionAnswering
|
| 5 |
from transformers import pipeline
|
| 6 |
import datetime
|
| 7 |
|
| 8 |
# Load the data
|
| 9 |
df = pd.read_excel('discrepantes.xlsx')
|
| 10 |
df.fillna(0, inplace=True)
|
| 11 |
-
table_data = df.astype(str)
|
| 12 |
-
print(table_data.head())
|
| 13 |
|
| 14 |
# Function to generate a response using the TAPEX model
|
| 15 |
def response(user_question, table_data):
|
| 16 |
a = datetime.datetime.now()
|
| 17 |
|
| 18 |
-
model = TapasForQuestionAnswering.from_pretrained("google/tapas-base")
|
| 19 |
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
| 20 |
-
answer = tqa(table=
|
|
|
|
| 21 |
query_result = {
|
| 22 |
"Resposta": answer
|
| 23 |
}
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import torch
|
|
|
|
| 4 |
from transformers import pipeline
|
| 5 |
import datetime
|
| 6 |
|
| 7 |
# Load the data
|
| 8 |
df = pd.read_excel('discrepantes.xlsx')
|
| 9 |
df.fillna(0, inplace=True)
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Function to generate a response using the TAPEX model
|
| 12 |
def response(user_question, table_data):
|
| 13 |
a = datetime.datetime.now()
|
| 14 |
|
|
|
|
| 15 |
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
| 16 |
+
answer = tqa(table=table, query=question)['cells'][0]
|
| 17 |
+
|
| 18 |
query_result = {
|
| 19 |
"Resposta": answer
|
| 20 |
}
|