Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
| 6 |
+
|
| 7 |
+
query = "what is the highest delta onu rx power?"
|
| 8 |
+
|
| 9 |
+
def main(filepath, query):
|
| 10 |
+
|
| 11 |
+
tableau = pd.read_excel(filepath).head(20).astype(str)
|
| 12 |
+
result = tqa(table=tableau, query=query)["answer"]
|
| 13 |
+
return result
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=main,
|
| 18 |
+
inputs=[
|
| 19 |
+
gr.File(type="filepath", label="Upload XLSX file"),
|
| 20 |
+
gr.Textbox(type="text", label="Enter text"),
|
| 21 |
+
],
|
| 22 |
+
outputs=[gr.Textbox(type="text", label="Text Input Output")],
|
| 23 |
+
title="TM TableQA Test",
|
| 24 |
+
description="Upload an XLSX file and/or enter text, and the processed output will be displayed.",
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# Launch the Gradio interface
|
| 28 |
+
iface.launch()
|