Skip to content

Commit

Permalink
correction minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
CharleyDL committed May 1, 2024
1 parent 6a71c99 commit 9f40b86
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pages/correct_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand Down
1 change: 1 addition & 0 deletions pages/detect_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pages/save_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -467,14 +466,14 @@ 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']
else:
return None


@st.cache_data(show_spinner=False)
def get_archives_labelisation() -> Dict[str, Any]:
"""
Retrieve the archives labelisation data from the API.
Expand All @@ -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']
Expand Down Expand Up @@ -779,6 +779,7 @@ def update_zip_detect(index: int) -> None:
correct_label()



## ---------------------------- GLYPHS LABELISATION ------------------------- ##

def labelisation_setup(uploaded_file: UploadedFile) -> None:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 9f40b86

Please sign in to comment.