CognitiveScience commited on
Commit
27614c8
·
1 Parent(s): 81ab720

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -86,7 +86,7 @@ def ccogsphere(name: str, rate: int, celsci: str):
86
  db.close()
87
  r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [name,celsci]})
88
  #demo.load()
89
- inp=celsci.split(" ")
90
  inp=inp[0] + "+" + inp[1]
91
  result=ecf(inp)
92
  df=pd.DataFrame.from_dict(result["videos"])
@@ -127,11 +127,25 @@ def run_ecs(inp):
127
  return df
128
 
129
 
130
- def load_data():
131
  db = sqlite3.connect(DB_FILE)
132
  reviews, total_reviews = get_latest_reviews(db)
133
  db.close()
134
- return reviews, total_reviews
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  def load_data2():
136
  #result=run_ecs(celscie)
137
  #df = pd.DataFrame.from_dict(result["videos"])
@@ -167,7 +181,7 @@ with gr.Blocks() as demo:
167
  #run_actr()
168
  submit = gr.Button(value=".")
169
  submit.click(ccogsphere, [name, rate, celsci], [data2, data, count])
170
- demo.load(load_data, None, [data, count])
171
  @name.change(inputs=name, outputs=celsci,_js="window.location.reload()")
172
  @rate.change(inputs=rate, outputs=name,_js="window.location.reload()")
173
  @celsci.change(inputs=celsci, outputs=rate,_js="window.location.reload()")
@@ -175,7 +189,7 @@ with gr.Blocks() as demo:
175
  def secwork(name):
176
  #if name=="abc":
177
  #run_code()
178
- load_data()
179
  #return "Hello " + name + "!"
180
  with gr.Row():
181
  with gr.Column():
 
86
  db.close()
87
  r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [name,celsci]})
88
  #demo.load()
89
+ inp=celsci.split()
90
  inp=inp[0] + "+" + inp[1]
91
  result=ecf(inp)
92
  df=pd.DataFrame.from_dict(result["videos"])
 
127
  return df
128
 
129
 
130
+ def load_data(celsci: str):
131
  db = sqlite3.connect(DB_FILE)
132
  reviews, total_reviews = get_latest_reviews(db)
133
  db.close()
134
+ if celsci!="":
135
+ inp=celsci.split()
136
+ inp=inp[0] + "+" + inp[1]
137
+ result=ecf(inp)
138
+ df=pd.DataFrame.from_dict(result["videos"])
139
+ else:
140
+ # Creating a sample dataframe
141
+ df = pd.DataFrame({
142
+ "A" : [14, 4, 5, 4, 1],
143
+ "B" : [5, 2, 54, 3, 2],
144
+ "C" : [20, 20, 7, 3, 8],
145
+ "D" : [14, 3, 6, 2, 6],
146
+ "E" : [23, 45, 64, 32, 23]
147
+ })
148
+ return df, reviews, total_reviews
149
  def load_data2():
150
  #result=run_ecs(celscie)
151
  #df = pd.DataFrame.from_dict(result["videos"])
 
181
  #run_actr()
182
  submit = gr.Button(value=".")
183
  submit.click(ccogsphere, [name, rate, celsci], [data2, data, count])
184
+ demo.load(load_data, celsci, [data2, data, count])
185
  @name.change(inputs=name, outputs=celsci,_js="window.location.reload()")
186
  @rate.change(inputs=rate, outputs=name,_js="window.location.reload()")
187
  @celsci.change(inputs=celsci, outputs=rate,_js="window.location.reload()")
 
189
  def secwork(name):
190
  #if name=="abc":
191
  #run_code()
192
+ load_data("")
193
  #return "Hello " + name + "!"
194
  with gr.Row():
195
  with gr.Column():