File size: 733 Bytes
7e27ec9
 
1fbf7ae
 
 
 
 
 
6961637
1fbf7ae
 
 
7e27ec9
1fbf7ae
 
 
 
 
 
 
7e27ec9
6961637
1fbf7ae
6961637
1fbf7ae
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This is based on https://huggingface.co/spaces/Abbasid/TableQA

from transformers import pipeline
import pandas as pd
import gradio as gr

tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")

query = "How many points did Jaylen Brown score?"

def main(filepath, query):

  tableau = pd.read_csv(filepath).astype(str)
  result = tqa(table=tableau, query=query)["answer"]
  return result


iface = gr.Interface(
    fn=main,
    inputs=[
        gr.File(type="filepath", label="Upload csv"),
        gr.Textbox(type="text", label="What do you want to know?"),
    ],
    outputs=[gr.Textbox(type="text", label="The output will be here" , lines=3)]
)

# Launch the Gradio interface
iface.launch()