giobin commited on
Commit
31b5d12
·
verified ·
1 Parent(s): 8823c0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -15
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(selected_answer, not_enough_info):
83
  sample = dataset.iloc[st.session_state.index]
84
- st.session_state.results.append({
85
- "username": st.session_state.username,
86
- "id": sample["id"],
87
- "video_id": sample["video_id"],
88
- "answer1": sample["answer1"],
89
- "answer2": sample["answer2"],
90
- "selected_answer": selected_answer,
91
- "target": sample["target"],
92
- "not_enough_info": not_enough_info
93
- })
94
- st.session_state.index += 1
 
 
 
 
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="not_enough
140
- ::contentReference[oaicite:12]{index=12}
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)