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.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.