rjadr commited on
Commit
35ef9cd
·
1 Parent(s): 082fb3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -7
app.py CHANGED
@@ -228,18 +228,47 @@ def image_to_image(image, k=5):
228
 
229
  st.title("#ditaduranuncamais Data Explorer")
230
 
231
- # Check if the directory exists
232
- if not os.path.exists(model_dir):
233
- download_models()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  dataset = load_dataset()
236
  df = load_dataframe(dataset)
237
  image_model = load_img_model()
238
  text_model = load_txt_model()
239
 
240
- tab1, tab2, tab3 = st.tabs(["Data exploration", "Semantic search", "Stats"])
 
 
241
 
242
- with tab1:
243
  st.dataframe(
244
  data=filter_dataframe(df),
245
  # use_container_width=True,
@@ -254,7 +283,7 @@ with tab1:
254
  hide_index=True,
255
  )
256
 
257
- with tab2:
258
  tabs = ["Text to Text", "Text to Image", "Image to Image", "Image to Text"]
259
  selected_tab = st.radio("Select a search type", tabs)
260
 
@@ -343,7 +372,7 @@ with tab2:
343
  hide_index=True,
344
  )
345
 
346
- with tab3:
347
  st.markdown("### Time Series Analysis")
348
  # Dropdown to select variables
349
  variable = st.selectbox('Select Variable', ['Followers at Posting', 'Total Interactions', 'Likes', 'Comments'])
 
228
 
229
  st.title("#ditaduranuncamais Data Explorer")
230
 
231
+ def check_password():
232
+ """Returns `True` if the user had the correct password."""
233
+
234
+ def password_entered():
235
+ """Checks whether a password entered by the user is correct."""
236
+ if st.session_state["password"] == st.secrets["password"]:
237
+ st.session_state["password_correct"] = True
238
+ del st.session_state["password"] # don't store password
239
+ else:
240
+ st.session_state["password_correct"] = False
241
+
242
+ if "password_correct" not in st.session_state:
243
+ # First run, show input for password.
244
+ st.text_input(
245
+ "Password", type="password", on_change=password_entered, key="password"
246
+ )
247
+ return False
248
+ elif not st.session_state["password_correct"]:
249
+ # Password not correct, show input + error.
250
+ st.text_input(
251
+ "Password", type="password", on_change=password_entered, key="password"
252
+ )
253
+ st.error("😕 Password incorrect")
254
+ return False
255
+ else:
256
+ # Password correct.
257
+ return True
258
+
259
+ if not check_password():
260
+ st.stop()
261
 
262
  dataset = load_dataset()
263
  df = load_dataframe(dataset)
264
  image_model = load_img_model()
265
  text_model = load_txt_model()
266
 
267
+ menu_options = ["Data exploration", "Semantic search", "Stats"]
268
+ st.sidebar.markdown('## Menu')
269
+ selected_menu_option = st.sidebar.selectbox("Menu", menu_options)
270
 
271
+ if selected_menu_option == "Data exploration":
272
  st.dataframe(
273
  data=filter_dataframe(df),
274
  # use_container_width=True,
 
283
  hide_index=True,
284
  )
285
 
286
+ elif selected_menu_option == "Semantic search":
287
  tabs = ["Text to Text", "Text to Image", "Image to Image", "Image to Text"]
288
  selected_tab = st.radio("Select a search type", tabs)
289
 
 
372
  hide_index=True,
373
  )
374
 
375
+ elif selected_menu_option == "Stats":
376
  st.markdown("### Time Series Analysis")
377
  # Dropdown to select variables
378
  variable = st.selectbox('Select Variable', ['Followers at Posting', 'Total Interactions', 'Likes', 'Comments'])