Upload 3 files
Browse files- Dockerfile +12 -0
- app.py +32 -0
- requirements.txt +5 -0
Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.7-slim
|
2 |
+
|
3 |
+
WORKDIR /usr/src/tapas
|
4 |
+
|
5 |
+
COPY requirements.txt ./
|
6 |
+
|
7 |
+
RUN pip install -r requirements.txt \
|
8 |
+
&& rm -rf /root/.cache/pip
|
9 |
+
|
10 |
+
COPY . .
|
11 |
+
|
12 |
+
ENTRYPOINT ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from app.tapex import execute_query
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
def main():
|
6 |
+
description = "Querying a csv using TAPEX model. You can ask a question about tabular data. TAPAS model " \
|
7 |
+
"will produce the result. Finetuned TAPEX model runs on max 5000 rows and 20 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 (TAPEX)",
|
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()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==3.15.0
|
2 |
+
torch
|
3 |
+
transformers==4.25.1
|
4 |
+
tensorflow_probability
|
5 |
+
jinja2
|