Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from app.tapas import execute_query
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
def main():
|
6 |
+
description = "Querying a csv using TAPAS model. You can ask a question about tabular data. TAPAS model " \
|
7 |
+
"will produce the result. Finetuned TAPAS model runs on max 500 rows and 10 columns data. " \
|
8 |
+
"A sample data of shopify store sales is provided"
|
9 |
+
|
10 |
+
article = "<p style='text-align: center'><a href='https://unscrambl.com/' target='_blank'>Unscrambl</a> | <a href='https://huggingface.co/google/tapas-base-finetuned-wtq' target='_blank'>TAPAS Model</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=abaranovskij_tablequery' alt='visitor badge'></center>"
|
11 |
+
|
12 |
+
iface = gr.Interface(fn=execute_query,
|
13 |
+
inputs=[gr.Textbox(label="Search query"),
|
14 |
+
gr.File(label="CSV file")],
|
15 |
+
outputs=[gr.JSON(label="Result"),
|
16 |
+
gr.Dataframe(label="All data")],
|
17 |
+
examples=[
|
18 |
+
["What is the highest order_amount?", "shopify.csv"],
|
19 |
+
["Which user_id has the highest order_amount?", "shopify.csv"],
|
20 |
+
["Which payment method was used the most?", "shopify.csv"]
|
21 |
+
],
|
22 |
+
title="Table Question Answering (TAPAS)",
|
23 |
+
description=description,
|
24 |
+
article=article,
|
25 |
+
allow_flagging='never')
|
26 |
+
# Use this config when running on Docker
|
27 |
+
# iface.launch(server_name="0.0.0.0", server_port=7000)
|
28 |
+
iface.launch(enable_queue=True)
|
29 |
+
|
30 |
+
|
31 |
+
if __name__ == "__main__":
|
32 |
+
main()
|