File size: 2,730 Bytes
c3b0ed3
 
 
 
 
 
 
 
 
 
 
 
fe2f983
c3b0ed3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0136e3d
c3b0ed3
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python
# coding: utf-8

# ## Using Gradio to create a simple interface.
# 
# Check out the library on [github](https://github.com/gradio-app/gradio-UI) and see the [getting started](https://gradio.app/getting_started.html) page for more demos.

# We'll start with a basic function that greets an input name.

# In[1]:


# get_ipython().system('pip install -q gradio')


# Now we'll wrap this function with a Gradio interface.

# In[2]:


from transformers import pipeline
import pandas as pd

tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")


# In[ ]:


tsqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-sqa")


# In[ ]:


mstqa = pipeline(task="table-question-answering", model="microsoft/tapex-large-finetuned-wikisql")


# In[ ]:


mswtqa = pipeline(task="table-question-answering", model="microsoft/tapex-large-finetuned-wtq")


# In[6]:


table2 = pd.read_excel("/content/Sample.xlsx").astype(str)
table3 = table2.head(20)


# In[7]:


table3


# In[ ]:


#t4 = table3.reset_index()
table4


# In[9]:


query = "what is the highest delta onu rx power?"
query2 = "what is the lowest delta onu rx power?"
query3 = "what is the most frequent login id?"
query4 = "how many rows with nan values are there?"
query5 = "how many S2 values are there"


# In[11]:


result = tsqa(table=table3, query=query5)["answer"]
result


# In[12]:


from collections import Counter
Counter(result)


# In[13]:


#mstqa(table=table4, query=query1)["answer"]


# In[14]:


mswtqa(table=table3, query=query5)["answer"]


# In[15]:


def main(filepath, query):

  table5 = pd.read_excel(filepath).head(20).astype(str)
  result = tsqa(table=table5, query=query)["answer"]
  return result

#greet("World")


# In[16]:


import gradio as gr

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="Multi-input Processor",
    description="Upload an XLSX file and/or enter text, and the processed output will be displayed.",
)

# Launch the Gradio interface
iface.launch()


# In[34]:


import os
import subprocess

# Use subprocess to execute the shell command
subprocess.run(["jupyter", "nbconvert", "--to", "script", "--format", "script", "--output", "/content/", "/content/drive/MyDrive/Colab Notebooks/NEW TableQA-GRADIO: Hello World.ipynb"])


# In[19]:


# get_ipython().system('gradio deploy')



# That's all! Go ahead and open that share link in a new tab. Check out our [getting started](https://gradio.app/getting_started.html) page for more complicated demos.