I have a problem, I’m trying to retrieve the label that the user would like to modify. I use a selectbox to get the list of possible labels.
But when the new label is selected, it retrieves the old one, and not the new one.
Here my code :
def select_correct_glyph(rowImgDet, idx: int):
all_mzl = all_mzl_info('list')
default_index = 0
if st.session_state.zip_detect[idx][1][0]:
default_index = st.session_state.zip_detect[idx][1][0] - 1
print(st.session_state.zip_detect[idx][1][0])
print(default_index)
print(all_mzl[default_index])
new_label = rowImgDet.selectbox("Correct Label",
options=all_mzl,
key=f"label_{idx}",
index=default_index,
label_visibility='hidden')
return new_label
clear_session_state('preview_imgs')
tmp_img.empty()
# all_mzl = all_mzl_info('list')
# default_index = 0
## - Correct the label of the detected glyphs
for i, result in enumerate(st.session_state.zip_detect):
space()
rowImgDet = row([0.3, 0.7], gap='small')
rowImgDet.image(result[0])
test = select_correct_glyph(rowImgDet, i)
print(test)
If you have any ideas about the problem, I’d love to hear from you! Thanks in advance!
That's more or less the basic logic. A prediction is made, I put everything in the zip_detect (one line = one prediction), and then if the person presses a button, the predictions go into the selectbox to change the result (in this case the prediction becomes a label), but when the selection of the new glyph is made it doesn't retrieve it, because it retrieves the one present in the index.