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 = "what is the highest delta onu rx power?" def main(filepath, query): tableau = pd.read_excel(filepath).head(20).astype(str) result = tqa(table=tableau, query=query)["answer"] return result iface = gr.Interface( fn=main, inputs=[ gr.File(type="filepath", label="Upload XLSX file"), gr.Textbox(type="text", label="Enter text"), ], outputs=[gr.Textbox(type="text", label="Text Input Output")], title="TM TableQA Test", description="Upload an XLSX file and/or enter text, and the processed output will be displayed.", ) # Launch the Gradio interface iface.launch()