File size: 1,707 Bytes
94ee912
b7dd467
 
 
 
8838bcf
 
fb72267
b7dd467
 
 
 
 
 
 
 
 
9c64f12
 
 
b7dd467
8838bcf
b7dd467
 
 
 
 
 
 
 
 
 
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
29
30
31
32
from app.tapex import execute_query
import gradio as gr


def main():
    description = "Querying a csv using TAPEX model. You can ask a question about tabular data. TAPAS model " \
                  "will produce the result. Finetuned TAPEX model runs on max 5000 rows and 20 columns data. " \
                  "A sample data of Retail sales data is provided"

    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>"

    iface = gr.Interface(fn=execute_query,
                         inputs=[gr.Textbox(label="Search query"),
                                 gr.File(label="CSV file")],
                         outputs=[gr.JSON(label="Result"),
                                  gr.Dataframe(label="All data")],
                         examples=[
                             ["What is the highest order_amount?", "Shopify.csv"],
                             ["Which user_id has the highest order_amount?", "Shopify.csv"],
                             ["Which payment method was used the most?", "Shopify.csv"]
                         ],
                         title="Table Question Answering (TAPEX)",
                         description=description,
                         article=article,
                         allow_flagging='never')
    # Use this config when running on Docker
    # iface.launch(server_name="0.0.0.0", server_port=7000)
    iface.launch(enable_queue=True)


if __name__ == "__main__":
    main()