Update src/streamlit_app.py
Browse files- src/streamlit_app.py +39 -30
src/streamlit_app.py
CHANGED
|
@@ -74,6 +74,9 @@ image_pairs = [
|
|
| 74 |
|
| 75 |
results = {}
|
| 76 |
|
|
|
|
|
|
|
|
|
|
| 77 |
# ---- LOOP THROUGH PAIRS ----
|
| 78 |
for i, (imgA, imgB) in enumerate(image_pairs):
|
| 79 |
st.markdown(f"### Pair {i+1}")
|
|
@@ -92,46 +95,52 @@ for i, (imgA, imgB) in enumerate(image_pairs):
|
|
| 92 |
results[f"pair_{i+1}"] = choice
|
| 93 |
|
| 94 |
# ---- SUBMIT ----
|
| 95 |
-
if st.button("Submit")
|
| 96 |
|
| 97 |
cont = 0
|
| 98 |
for key in results:
|
| 99 |
if results[key] == "-":
|
| 100 |
cont += 1
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
st.error("Sorry, you have not evaluated all pairs. Please, check again.")
|
| 103 |
else:
|
| 104 |
-
cont_r
|
| 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 |
# Save to file (you could also save to a database)
|
| 133 |
#with open("resp/responses.txt", "a") as f:
|
| 134 |
# f.write(str(results) + "\n")
|
| 135 |
-
|
| 136 |
-
st.success("Thanks. Only one submission is allowed.")
|
| 137 |
|
|
|
|
| 74 |
|
| 75 |
results = {}
|
| 76 |
|
| 77 |
+
|
| 78 |
+
code_prov = st.text_input("Insert provided code:")
|
| 79 |
+
|
| 80 |
# ---- LOOP THROUGH PAIRS ----
|
| 81 |
for i, (imgA, imgB) in enumerate(image_pairs):
|
| 82 |
st.markdown(f"### Pair {i+1}")
|
|
|
|
| 95 |
results[f"pair_{i+1}"] = choice
|
| 96 |
|
| 97 |
# ---- SUBMIT ----
|
| 98 |
+
if st.button("Submit"):
|
| 99 |
|
| 100 |
cont = 0
|
| 101 |
for key in results:
|
| 102 |
if results[key] == "-":
|
| 103 |
cont += 1
|
| 104 |
+
|
| 105 |
+
if code_prov is None:
|
| 106 |
+
st.error("Please, insert your provided code at the beginning of this form. Then submit again.")
|
| 107 |
+
elif cont != 0:
|
| 108 |
st.error("Sorry, you have not evaluated all pairs. Please, check again.")
|
| 109 |
else:
|
| 110 |
+
if cont_r == 0:
|
| 111 |
+
|
| 112 |
+
cont_r += 1
|
| 113 |
+
#st.success("Thank you! Your responses have been recorded.")
|
| 114 |
+
#st.write("Thank you! Your selection has been recorded.")
|
| 115 |
+
st.success("Thank you! Your selection has been recorded.")
|
| 116 |
+
#st.write("Your final selection is in the green box below. Please, copy them and send them to my email. Thanks a lot!")
|
| 117 |
+
#s_rp = "SELECTION: "
|
| 118 |
+
#for i in range(len(image_pairs)):
|
| 119 |
+
# if i == (len(image_pairs) - 1):
|
| 120 |
+
# s_rp = s_rp + results[f"pair_{i+1}"] + "."
|
| 121 |
+
# else:
|
| 122 |
+
# s_rp = s_rp + results[f"pair_{i+1}"] + ", "
|
| 123 |
+
##st.badge(s_rp, width = "stretch")
|
| 124 |
+
#st.success(s_rp)
|
| 125 |
+
|
| 126 |
+
# st.json(results)
|
| 127 |
|
| 128 |
+
#====
|
| 129 |
+
current_time = datetime.datetime.now()
|
| 130 |
+
results["day"] = str(current_time.day)
|
| 131 |
+
results["time"] = str(current_time.hour) + ":" + str(current_time.minute) + ":" + str(current_time.second)
|
| 132 |
+
results["code"] = code_prov
|
| 133 |
+
|
| 134 |
+
with scheduler.lock:
|
| 135 |
+
with feedback_file.open("a") as f:
|
| 136 |
+
f.write(json.dumps(results))
|
| 137 |
+
f.write("\n")
|
| 138 |
+
#====
|
| 139 |
+
else:
|
| 140 |
+
st.success("Thanks. Only one submission is allowed.")
|
| 141 |
|
| 142 |
# Save to file (you could also save to a database)
|
| 143 |
#with open("resp/responses.txt", "a") as f:
|
| 144 |
# f.write(str(results) + "\n")
|
| 145 |
+
|
|
|
|
| 146 |
|