taesiri commited on
Commit
ee44327
1 Parent(s): a942e66

testing a more compact demo

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -23,7 +23,7 @@ random.seed(datetime.now())
23
  np.random.seed(int(time.time()))
24
 
25
  NUMBER_OF_TRIALS = 20
26
- CLASSIFIER_TAG = "CHM"
27
  explaination_functions = [load_chm_nns, load_knn_nns]
28
  selected_xai_tool = None
29
 
@@ -122,7 +122,7 @@ def render_experiment(query):
122
  class_def = class_descriptions[predicted_wnid]
123
 
124
  session_state.is_classifier_correct[query_id] = classifier_predictions[query_id][
125
- f"{CLASSIFIER_TAG}-Output"
126
  ]
127
 
128
  ################################### SHOW QUERY and PREDICTION
@@ -142,7 +142,6 @@ def render_experiment(query):
142
  use_column_width=True,
143
  )
144
 
145
-
146
  default_value = 0
147
  if query_id in session_state.user_feedback.keys():
148
  if session_state.user_feedback[query_id] == "Correct":
@@ -176,7 +175,8 @@ def render_experiment(query):
176
  def render_results():
177
  user_correct_guess = 0
178
  for q in session_state.user_feedback.keys():
179
- if session_state.is_classifier_correct[q] == session_state.user_feedback[q]:
 
180
  user_correct_guess += 1
181
 
182
  st.write(
@@ -336,12 +336,16 @@ def main():
336
  global app_mode
337
  global session_state
338
  global selected_xai_tool
 
339
 
340
  # Set the session state
341
  # State Management and General Setup
342
  st.set_page_config(layout="wide")
343
  st.title("TASK - 1 - ImageNetREAL")
344
 
 
 
 
345
  options = [
346
  "Unselected",
347
  "NOXAI",
@@ -376,11 +380,11 @@ def main():
376
  st.markdown(f"## SELECTED METHOD ``{session_state.XAI_tool}``")
377
 
378
  if session_state.XAI_tool == "NOXAI":
 
379
  selected_xai_tool = None
380
- CLASSIFIER_TAG = "KNN"
381
  elif session_state.XAI_tool == "KNN":
382
  selected_xai_tool = load_knn_nns
383
- CLASSIFIER_TAG = "KNN"
384
  elif session_state.XAI_tool == "CHM Nearest Neighbors":
385
  selected_xai_tool = load_chm_nns
386
  CLASSIFIER_TAG = "CHM"
 
23
  np.random.seed(int(time.time()))
24
 
25
  NUMBER_OF_TRIALS = 20
26
+ CLASSIFIER_TAG = ""
27
  explaination_functions = [load_chm_nns, load_knn_nns]
28
  selected_xai_tool = None
29
 
 
122
  class_def = class_descriptions[predicted_wnid]
123
 
124
  session_state.is_classifier_correct[query_id] = classifier_predictions[query_id][
125
+ f"{CLASSIFIER_TAG.upper()}-Output"
126
  ]
127
 
128
  ################################### SHOW QUERY and PREDICTION
 
142
  use_column_width=True,
143
  )
144
 
 
145
  default_value = 0
146
  if query_id in session_state.user_feedback.keys():
147
  if session_state.user_feedback[query_id] == "Correct":
 
175
  def render_results():
176
  user_correct_guess = 0
177
  for q in session_state.user_feedback.keys():
178
+ uf = True if session_state.user_feedback[q] == 'Correct' else False
179
+ if session_state.is_classifier_correct[q] == uf:
180
  user_correct_guess += 1
181
 
182
  st.write(
 
336
  global app_mode
337
  global session_state
338
  global selected_xai_tool
339
+ global CLASSIFIER_TAG
340
 
341
  # Set the session state
342
  # State Management and General Setup
343
  st.set_page_config(layout="wide")
344
  st.title("TASK - 1 - ImageNetREAL")
345
 
346
+ # st.write(classifier_predictions.keys())
347
+ # st.write(classifier_predictions["ILSVRC2012_val_00024646.JPEG"])
348
+
349
  options = [
350
  "Unselected",
351
  "NOXAI",
 
380
  st.markdown(f"## SELECTED METHOD ``{session_state.XAI_tool}``")
381
 
382
  if session_state.XAI_tool == "NOXAI":
383
+ CLASSIFIER_TAG = "knn"
384
  selected_xai_tool = None
 
385
  elif session_state.XAI_tool == "KNN":
386
  selected_xai_tool = load_knn_nns
387
+ CLASSIFIER_TAG = "knn"
388
  elif session_state.XAI_tool == "CHM Nearest Neighbors":
389
  selected_xai_tool = load_chm_nns
390
  CLASSIFIER_TAG = "CHM"