From 9f40b8686fd0f59ea43f6af137fe59ca2bb70db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charley=20=E2=88=86=2E=20L=2E?= Date: Wed, 1 May 2024 19:13:23 +0200 Subject: [PATCH] correction minor bugs --- pages/correct_label.py | 4 +++- pages/detect_page.py | 1 + pages/save_result.py | 4 ++-- utils/functions.py | 9 ++++----- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pages/correct_label.py b/pages/correct_label.py index 69f192a..6c31c3c 100644 --- a/pages/correct_label.py +++ b/pages/correct_label.py @@ -102,11 +102,13 @@ if not validate: if st.session_state.zip_detect: for i, result in enumerate(st.session_state.zip_detect): + default_index = st.session_state.zip_detect[i][1][0] - 1 + rowImgDet.image(result[0]) new_label = rowImgDet.selectbox("Correct Label", ALL_MZL, key=f"label_{i}", - index=st.session_state.zip_detect[i][1][0] - 1, + index=default_index, label_visibility='hidden', on_change=fct.update_zip_detect, args=(i,)) diff --git a/pages/detect_page.py b/pages/detect_page.py index 81bbd5d..a688579 100644 --- a/pages/detect_page.py +++ b/pages/detect_page.py @@ -94,6 +94,7 @@ ## - clear session state for correct page fct.clear_session_state('correct_label') fct.clear_session_state('del_label') +fct.clear_session_state('rects_correct') ## - Upload file to classify glyphs if uploaded_file is not None: diff --git a/pages/save_result.py b/pages/save_result.py index 4995e2c..298d9e9 100644 --- a/pages/save_result.py +++ b/pages/save_result.py @@ -131,13 +131,13 @@ ## -- Send Corrected Glyphs to the API and display the message - annot_results = fct.save_labelisation(img_name, + label_results = fct.save_labelisation(img_name, img, bbox_img, st.session_state.rects_correct, st.session_state.correct_label) - for i, result in enumerate(annot_results): + for i, result in enumerate(label_results): if result['result']: st.toast(result['message'], icon='✅') else: diff --git a/utils/functions.py b/utils/functions.py index 7cfc4b6..bf83e73 100644 --- a/utils/functions.py +++ b/utils/functions.py @@ -455,7 +455,6 @@ def display_archives_labelisation(labelisation_dict: Dict[str, dict]) -> None: """, unsafe_allow_html=True) -@st.cache_data(show_spinner=False) def get_archives_classification() -> Dict[str, Any]: """ Retrieve the archives classification data from the API. @@ -467,6 +466,7 @@ def get_archives_classification() -> Dict[str, Any]: """ res = requests.get(url=f"{API_URL}/archives/classification/") # print(res.json()) + res_json = res.json() if 'content' in res_json: return res_json['content'] @@ -474,7 +474,6 @@ def get_archives_classification() -> Dict[str, Any]: return None -@st.cache_data(show_spinner=False) def get_archives_labelisation() -> Dict[str, Any]: """ Retrieve the archives labelisation data from the API. @@ -486,6 +485,7 @@ def get_archives_labelisation() -> Dict[str, Any]: """ res = requests.get(url=f"{API_URL}/archives/labelisation/") # print(res.json()) + res_json = res.json() if 'content' in res_json: return res_json['content'] @@ -779,6 +779,7 @@ def update_zip_detect(index: int) -> None: correct_label() + ## ---------------------------- GLYPHS LABELISATION ------------------------- ## def labelisation_setup(uploaded_file: UploadedFile) -> None: @@ -912,11 +913,9 @@ def save_labelisation(img_name: str, "mzl_number": mzl_number } - print(data) res = requests.post(url=f"{API_URL}/labelisation/saving_annotation/", data=json.dumps(data)) - print(res.json()) results.append(res.json()) return results @@ -971,7 +970,7 @@ def save_inference(img_name: str, res = requests.post(url=f"{API_URL}/prediction/saving_classification/", data=json.dumps(data)) - print(res.json()) + results.append(res.json()) return results