CarolineM5 commited on
Commit
1bca2f2
·
verified ·
1 Parent(s): efe8624

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -17,7 +17,7 @@ import numpy as np
17
  # -------------------------
18
  IMAGE_DIR = "images" # Folder containing images
19
  NUM_PAIRS = 10 # Total number of pairs to be assessed
20
- # RESULTS_FILE = "results.csv" # CSV file for saving responses
21
 
22
  # -------------------------
23
  # Helper functions
@@ -32,6 +32,9 @@ def load_image_pair(index):
32
  pred_path = os.path.join(IMAGE_DIR, f"{idx_str}_gen0.png")
33
  return gt_path, pred_path
34
 
 
 
 
35
 
36
 
37
  # -------------------------
@@ -109,9 +112,11 @@ if st.session_state.page == "evaluation":
109
 
110
  st.success(f"Number of correct answers: {nb_correct}/{NUM_PAIRS}")
111
 
112
- d = {'ID_img': st.session_state.list_pair_ID, 'Correct': correct_guess}
113
- df = pd.DataFrame(data=d)
114
- df.to_csv(st.session_state.user_name+'.csv')
 
 
115
 
116
  st.stop()
117
 
 
17
  # -------------------------
18
  IMAGE_DIR = "images" # Folder containing images
19
  NUM_PAIRS = 10 # Total number of pairs to be assessed
20
+ RESULTS_FILE = "results.csv" # CSV file for saving responses
21
 
22
  # -------------------------
23
  # Helper functions
 
32
  pred_path = os.path.join(IMAGE_DIR, f"{idx_str}_gen0.png")
33
  return gt_path, pred_path
34
 
35
+ def form_callback(name, imgID, correct):
36
+ with open(RESULTS_FILE, 'a+') as f: #Append & read mode
37
+ f.write(f"{name},{imgID},{correct}\n")
38
 
39
 
40
  # -------------------------
 
112
 
113
  st.success(f"Number of correct answers: {nb_correct}/{NUM_PAIRS}")
114
 
115
+ # d = {'ID_img': st.session_state.list_pair_ID, 'Correct': correct_guess}
116
+ # df = pd.DataFrame(data=d)
117
+ # df.to_csv(st.session_state.user_name+'.csv')
118
+
119
+ form_callback(st.session_state.user_name, st.session_state.list_pair_ID, correct_guess)
120
 
121
  st.stop()
122