Commit
·
613e563
1
Parent(s):
6348b4e
add empty checkbox check at the finish button click
Browse files
app.py
CHANGED
|
@@ -101,18 +101,18 @@ def main():
|
|
| 101 |
count = state if isinstance(state, int) else state.value
|
| 102 |
return f"### Target class: {class_names[count]}"
|
| 103 |
|
| 104 |
-
def update_buttons(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
count = state if isinstance(state, int) else state.value
|
| 106 |
max_images = config['dataset'][config['dataset']['name']]['n_classes']
|
| 107 |
finish_button = gr.Button("Finish", visible=(count == max_images-1))
|
| 108 |
-
submit_button = gr.Button("Submit", visible=
|
| 109 |
-
continue_button = gr.Button("Continue", visible=(count != max_images-1))
|
| 110 |
-
return continue_button, submit_button, finish_button
|
| 111 |
-
|
| 112 |
-
def update_continue_button():
|
| 113 |
continue_button = gr.Button("Continue", visible=False)
|
| 114 |
-
|
| 115 |
-
return continue_button, submit_button
|
| 116 |
|
| 117 |
|
| 118 |
def update_checkbox(user_state):
|
|
@@ -211,8 +211,7 @@ def main():
|
|
| 211 |
outputs=target_img_label
|
| 212 |
).then(
|
| 213 |
update_buttons,
|
| 214 |
-
|
| 215 |
-
outputs={continue_button, submit_button, finish_button}
|
| 216 |
).then(
|
| 217 |
hide_checkbox,
|
| 218 |
outputs=concept_checkboxes
|
|
@@ -228,7 +227,8 @@ def main():
|
|
| 228 |
|
| 229 |
continue_button.click(
|
| 230 |
update_continue_button,
|
| 231 |
-
|
|
|
|
| 232 |
).then(
|
| 233 |
update_checkbox,
|
| 234 |
inputs=user_state,
|
|
@@ -236,6 +236,13 @@ def main():
|
|
| 236 |
)
|
| 237 |
|
| 238 |
finish_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
add_answer, inputs=[concept_checkboxes, answers],outputs=answers
|
| 240 |
).then(
|
| 241 |
save_results, inputs=answers
|
|
|
|
| 101 |
count = state if isinstance(state, int) else state.value
|
| 102 |
return f"### Target class: {class_names[count]}"
|
| 103 |
|
| 104 |
+
def update_buttons():
|
| 105 |
+
submit_button = gr.Button("Submit", visible=False)
|
| 106 |
+
continue_button = gr.Button("Continue", visible=True)
|
| 107 |
+
return continue_button, submit_button
|
| 108 |
+
|
| 109 |
+
def update_continue_button(state):
|
| 110 |
count = state if isinstance(state, int) else state.value
|
| 111 |
max_images = config['dataset'][config['dataset']['name']]['n_classes']
|
| 112 |
finish_button = gr.Button("Finish", visible=(count == max_images-1))
|
| 113 |
+
submit_button = gr.Button("Submit", visible=(count != max_images-1))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
continue_button = gr.Button("Continue", visible=False)
|
| 115 |
+
return continue_button, submit_button, finish_button
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
def update_checkbox(user_state):
|
|
|
|
| 211 |
outputs=target_img_label
|
| 212 |
).then(
|
| 213 |
update_buttons,
|
| 214 |
+
outputs={continue_button, submit_button}
|
|
|
|
| 215 |
).then(
|
| 216 |
hide_checkbox,
|
| 217 |
outputs=concept_checkboxes
|
|
|
|
| 227 |
|
| 228 |
continue_button.click(
|
| 229 |
update_continue_button,
|
| 230 |
+
inputs=user_state,
|
| 231 |
+
outputs={continue_button, submit_button, finish_button}
|
| 232 |
).then(
|
| 233 |
update_checkbox,
|
| 234 |
inputs=user_state,
|
|
|
|
| 236 |
)
|
| 237 |
|
| 238 |
finish_button.click(
|
| 239 |
+
check_answer,
|
| 240 |
+
inputs=concept_checkboxes
|
| 241 |
+
).success(
|
| 242 |
+
update_state,
|
| 243 |
+
inputs=user_state,
|
| 244 |
+
outputs=user_state
|
| 245 |
+
).then(
|
| 246 |
add_answer, inputs=[concept_checkboxes, answers],outputs=answers
|
| 247 |
).then(
|
| 248 |
save_results, inputs=answers
|