Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,19 +79,23 @@ def push_to_hf_hub(csv_path):
|
|
| 79 |
print(f"Error pushing to HF: {e}")
|
| 80 |
|
| 81 |
# Function to save user choice
|
| 82 |
-
def save_choice(
|
| 83 |
sample = dataset.iloc[st.session_state.index]
|
| 84 |
-
st.session_state.
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
# Save results and push to Hugging Face Hub if all samples are labeled
|
| 97 |
if st.session_state.index >= len(dataset):
|
|
@@ -136,6 +140,7 @@ with st.form("annotation_form"):
|
|
| 136 |
)
|
| 137 |
|
| 138 |
# Independent checkbox for insufficient information
|
| 139 |
-
not_enough_info = st.checkbox("The frame does not provide enough information to answer the question.", key="
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
| 79 |
print(f"Error pushing to HF: {e}")
|
| 80 |
|
| 81 |
# Function to save user choice
|
| 82 |
+
def save_choice():
|
| 83 |
sample = dataset.iloc[st.session_state.index]
|
| 84 |
+
selected_answer = st.session_state.get("selected_answer", None)
|
| 85 |
+
not_enough_info = st.session_state.get("not_enough_info", False)
|
| 86 |
+
|
| 87 |
+
if selected_answer is not None:
|
| 88 |
+
st.session_state.results.append({
|
| 89 |
+
"username": st.session_state.username,
|
| 90 |
+
"id": sample["id"],
|
| 91 |
+
"video_id": sample["video_id"],
|
| 92 |
+
"answer1": sample["answer1"],
|
| 93 |
+
"answer2": sample["answer2"],
|
| 94 |
+
"selected_answer": selected_answer,
|
| 95 |
+
"target": sample["target"],
|
| 96 |
+
"not_enough_info": not_enough_info
|
| 97 |
+
})
|
| 98 |
+
st.session_state.index += 1
|
| 99 |
|
| 100 |
# Save results and push to Hugging Face Hub if all samples are labeled
|
| 101 |
if st.session_state.index >= len(dataset):
|
|
|
|
| 140 |
)
|
| 141 |
|
| 142 |
# Independent checkbox for insufficient information
|
| 143 |
+
not_enough_info = st.checkbox("The frame does not provide enough information to answer the question.", key="not_enough_info")
|
| 144 |
+
|
| 145 |
+
# Submit button
|
| 146 |
+
submit_button = st.form_submit_button("Next", on_click=save_choice)
|