Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -347,6 +347,7 @@ def render_rupture_markers_widget(index: int, choices: list[str]):
|
|
| 347 |
st.session_state[count_key] = 1
|
| 348 |
|
| 349 |
count = st.session_state[count_key]
|
|
|
|
| 350 |
st.markdown("**What rupture markers are found?** *(one per row; max 8)*")
|
| 351 |
|
| 352 |
for i in range(1, count + 1):
|
|
@@ -366,36 +367,27 @@ def render_rupture_markers_widget(index: int, choices: list[str]):
|
|
| 366 |
if st.session_state.get(marker_key) is not None else 0
|
| 367 |
)
|
| 368 |
with col2:
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
|
|
|
| 372 |
with col3:
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
|
|
|
| 376 |
|
| 377 |
st.markdown("---")
|
| 378 |
|
| 379 |
a_col, b_col = st.columns([1, 1])
|
| 380 |
-
|
| 381 |
-
def _inc():
|
| 382 |
-
st.session_state[count_key] = min(MAX_RUPTURE_MARKERS, st.session_state[count_key] + 1)
|
| 383 |
-
|
| 384 |
-
def _dec():
|
| 385 |
-
st.session_state[count_key] = max(1, st.session_state[count_key] - 1)
|
| 386 |
-
|
| 387 |
with a_col:
|
| 388 |
-
st.
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
on_click=_inc,
|
| 392 |
-
)
|
| 393 |
with b_col:
|
| 394 |
-
st.
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
on_click=_dec,
|
| 398 |
-
)
|
| 399 |
|
| 400 |
st.caption(f"{st.session_state[count_key]}/{MAX_RUPTURE_MARKERS} markers")
|
| 401 |
|
|
@@ -474,8 +466,8 @@ def show_field(f: Field, index: int, data_collected):
|
|
| 474 |
show_field(child, index, data_collected)
|
| 475 |
case 'skip_checkbox':
|
| 476 |
st.checkbox(f.title, key=f.name, value=False)
|
| 477 |
-
case 'rupture_markers':
|
| 478 |
-
|
| 479 |
else:
|
| 480 |
key = f.name + str(index)
|
| 481 |
st.session_state.data_inputs_keys.append(f.name)
|
|
@@ -653,7 +645,7 @@ div[data-testid="stMarkdownContainer"] > p {
|
|
| 653 |
|
| 654 |
def add_annotation_guidelines():
|
| 655 |
guidelines_text = load_text("texts/guidelines.md")
|
| 656 |
-
st.write(f"username is {st.session_state.user_id}")
|
| 657 |
st.markdown(
|
| 658 |
f"<details><summary><b>Annotation Guidelines</b></summary><div>{guidelines_text}</div></details><br>",
|
| 659 |
unsafe_allow_html=True)
|
|
@@ -745,6 +737,7 @@ elif st.session_state.current_index < len(st.session_state.data):
|
|
| 745 |
#add_annotation_guidelines()
|
| 746 |
with st.form("data_form"+str(st.session_state.current_index)):
|
| 747 |
show_fields(fields)
|
|
|
|
| 748 |
|
| 749 |
elif st.session_state.current_index == len(st.session_state.data):
|
| 750 |
st.write(f"**Thank you for taking part in this study!** \n ")
|
|
|
|
| 347 |
st.session_state[count_key] = 1
|
| 348 |
|
| 349 |
count = st.session_state[count_key]
|
| 350 |
+
|
| 351 |
st.markdown("**What rupture markers are found?** *(one per row; max 8)*")
|
| 352 |
|
| 353 |
for i in range(1, count + 1):
|
|
|
|
| 367 |
if st.session_state.get(marker_key) is not None else 0
|
| 368 |
)
|
| 369 |
with col2:
|
| 370 |
+
if RUPTURE_LINE_INPUT_TYPE == "number":
|
| 371 |
+
st.number_input("Lines: from", min_value=0, step=1, key=a_key)
|
| 372 |
+
else:
|
| 373 |
+
st.text_input("Lines: from", key=a_key, value=st.session_state.get(a_key, ""))
|
| 374 |
with col3:
|
| 375 |
+
if RUPTURE_LINE_INPUT_TYPE == "number":
|
| 376 |
+
st.number_input("Lines: to", min_value=0, step=1, key=b_key)
|
| 377 |
+
else:
|
| 378 |
+
st.text_input("Lines: to", key=b_key, value=st.session_state.get(b_key, ""))
|
| 379 |
|
| 380 |
st.markdown("---")
|
| 381 |
|
| 382 |
a_col, b_col = st.columns([1, 1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
with a_col:
|
| 384 |
+
if st.button("➕ Add another rupture marker", disabled=(count >= MAX_RUPTURE_MARKERS)):
|
| 385 |
+
st.session_state[count_key] = min(MAX_RUPTURE_MARKERS, count + 1)
|
| 386 |
+
st.rerun()
|
|
|
|
|
|
|
| 387 |
with b_col:
|
| 388 |
+
if st.button("➖ Remove last", disabled=(count <= 1)):
|
| 389 |
+
st.session_state[count_key] = max(1, count - 1)
|
| 390 |
+
st.rerun()
|
|
|
|
|
|
|
| 391 |
|
| 392 |
st.caption(f"{st.session_state[count_key]}/{MAX_RUPTURE_MARKERS} markers")
|
| 393 |
|
|
|
|
| 466 |
show_field(child, index, data_collected)
|
| 467 |
case 'skip_checkbox':
|
| 468 |
st.checkbox(f.title, key=f.name, value=False)
|
| 469 |
+
#case 'rupture_markers':
|
| 470 |
+
# render_rupture_markers_widget(index, rupture_choices)
|
| 471 |
else:
|
| 472 |
key = f.name + str(index)
|
| 473 |
st.session_state.data_inputs_keys.append(f.name)
|
|
|
|
| 645 |
|
| 646 |
def add_annotation_guidelines():
|
| 647 |
guidelines_text = load_text("texts/guidelines.md")
|
| 648 |
+
#st.write(f"username is {st.session_state.user_id}")
|
| 649 |
st.markdown(
|
| 650 |
f"<details><summary><b>Annotation Guidelines</b></summary><div>{guidelines_text}</div></details><br>",
|
| 651 |
unsafe_allow_html=True)
|
|
|
|
| 737 |
#add_annotation_guidelines()
|
| 738 |
with st.form("data_form"+str(st.session_state.current_index)):
|
| 739 |
show_fields(fields)
|
| 740 |
+
render_rupture_markers_widget(st.session_state.current_index, rupture_choices)
|
| 741 |
|
| 742 |
elif st.session_state.current_index == len(st.session_state.data):
|
| 743 |
st.write(f"**Thank you for taking part in this study!** \n ")
|