Spaces:
Sleeping
Sleeping
feat: functional cetacean classifier
Browse files
src/classifier/classifier_image.py
CHANGED
|
@@ -109,10 +109,6 @@ def cetacean_show_results_and_review() -> None:
|
|
| 109 |
selected_class = st.selectbox(f"Species for observation {str(o)}", viewer.WHALE_CLASSES, index=ix)
|
| 110 |
|
| 111 |
_observation.set_selected_class(selected_class)
|
| 112 |
-
#observation['predicted_class'] = selected_class
|
| 113 |
-
# this logic is now in the InputObservation class automatially
|
| 114 |
-
#if selected_class != st.session_state.whale_prediction1[hash]:
|
| 115 |
-
# observation['class_overriden'] = selected_class # TODO: this should be boolean!
|
| 116 |
|
| 117 |
# store the elements of the observation that will be transmitted (not image)
|
| 118 |
observation = _observation.to_dict()
|
|
@@ -163,27 +159,6 @@ def cetacean_show_results():
|
|
| 163 |
|
| 164 |
with grid[col]:
|
| 165 |
st.image(image, use_column_width=True)
|
| 166 |
-
|
| 167 |
-
# # dropdown for selecting/overriding the species prediction
|
| 168 |
-
# if not st.session_state.classify_whale_done[hash]:
|
| 169 |
-
# selected_class = st.sidebar.selectbox("Species", viewer.WHALE_CLASSES,
|
| 170 |
-
# index=None, placeholder="Species not yet identified...",
|
| 171 |
-
# disabled=True)
|
| 172 |
-
# else:
|
| 173 |
-
# pred1 = st.session_state.whale_prediction1[hash]
|
| 174 |
-
# # get index of pred1 from WHALE_CLASSES, none if not present
|
| 175 |
-
# print(f"[D] pred1: {pred1}")
|
| 176 |
-
# ix = viewer.WHALE_CLASSES.index(pred1) if pred1 in viewer.WHALE_CLASSES else None
|
| 177 |
-
# selected_class = st.selectbox(f"Species for observation {str(o)}", viewer.WHALE_CLASSES, index=ix)
|
| 178 |
-
|
| 179 |
-
# observation['predicted_class'] = selected_class
|
| 180 |
-
# if selected_class != st.session_state.whale_prediction1[hash]:
|
| 181 |
-
# observation['class_overriden'] = selected_class # TODO: this should be boolean!
|
| 182 |
-
|
| 183 |
-
# st.session_state.public_observation = observation
|
| 184 |
-
|
| 185 |
-
#st.button(f"Upload observation {str(o)} to THE INTERNET!", on_click=push_observations)
|
| 186 |
-
#
|
| 187 |
st.markdown(metadata2md(hash, debug=True))
|
| 188 |
|
| 189 |
msg = f"[D] full observation after inference: {observation}"
|
|
|
|
| 109 |
selected_class = st.selectbox(f"Species for observation {str(o)}", viewer.WHALE_CLASSES, index=ix)
|
| 110 |
|
| 111 |
_observation.set_selected_class(selected_class)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
# store the elements of the observation that will be transmitted (not image)
|
| 114 |
observation = _observation.to_dict()
|
|
|
|
| 159 |
|
| 160 |
with grid[col]:
|
| 161 |
st.image(image, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
st.markdown(metadata2md(hash, debug=True))
|
| 163 |
|
| 164 |
msg = f"[D] full observation after inference: {observation}"
|
src/pages/3_🔥_classifiers.py
CHANGED
|
@@ -35,8 +35,6 @@ dataset_id = "Saving-Willy/temp_dataset"
|
|
| 35 |
data_files = "data/train-00000-of-00001.parquet"
|
| 36 |
############################################################
|
| 37 |
|
| 38 |
-
st.sidebar.success("classifiers")
|
| 39 |
-
|
| 40 |
# Streamlit app
|
| 41 |
tab_inference, tab_hotdogs= \
|
| 42 |
st.tabs(["Cetecean classifier", "Hotdog classifier"])
|
|
@@ -67,7 +65,7 @@ if st.session_state.workflow_fsm.is_in_state('data_entry_complete'):
|
|
| 67 |
if st.sidebar.button(":white_check_mark:[**Validate**]"):
|
| 68 |
# create a dictionary with the submitted observation
|
| 69 |
|
| 70 |
-
#
|
| 71 |
#tab_log.info(f"{st.session_state.observations}")
|
| 72 |
|
| 73 |
df = pd.DataFrame([obs.to_dict() for obs in st.session_state.observations.values()])
|
|
@@ -118,7 +116,9 @@ elif st.session_state.workflow_fsm.is_in_state('ml_classification_completed'):
|
|
| 118 |
st.markdown(s)
|
| 119 |
|
| 120 |
# add a button to advance the state
|
| 121 |
-
if st.button("
|
|
|
|
|
|
|
| 122 |
st.session_state.workflow_fsm.complete_current_state()
|
| 123 |
# -> manual_inspection_completed
|
| 124 |
st.rerun()
|
|
@@ -130,7 +130,8 @@ elif st.session_state.workflow_fsm.is_in_state('manual_inspection_completed'):
|
|
| 130 |
st.markdown("""### Inference Results (after manual validation) """)
|
| 131 |
|
| 132 |
|
| 133 |
-
if st.button("Upload all observations to THE INTERNET!"
|
|
|
|
| 134 |
# let this go through to the push_all func, since it just reports to log for now.
|
| 135 |
push_all_observations(enable_push=False)
|
| 136 |
st.session_state.workflow_fsm.complete_current_state()
|
|
@@ -146,7 +147,6 @@ elif st.session_state.workflow_fsm.is_in_state('data_uploaded'):
|
|
| 146 |
cetacean_show_results()
|
| 147 |
|
| 148 |
st.divider()
|
| 149 |
-
#df = pd.DataFrame(st.session_state.observations, index=[0])
|
| 150 |
df = pd.DataFrame([obs.to_dict() for obs in st.session_state.observations.values()])
|
| 151 |
st.table(df)
|
| 152 |
|
|
|
|
| 35 |
data_files = "data/train-00000-of-00001.parquet"
|
| 36 |
############################################################
|
| 37 |
|
|
|
|
|
|
|
| 38 |
# Streamlit app
|
| 39 |
tab_inference, tab_hotdogs= \
|
| 40 |
st.tabs(["Cetecean classifier", "Hotdog classifier"])
|
|
|
|
| 65 |
if st.sidebar.button(":white_check_mark:[**Validate**]"):
|
| 66 |
# create a dictionary with the submitted observation
|
| 67 |
|
| 68 |
+
# TODO NEED TO ADAPT to multipage
|
| 69 |
#tab_log.info(f"{st.session_state.observations}")
|
| 70 |
|
| 71 |
df = pd.DataFrame([obs.to_dict() for obs in st.session_state.observations.values()])
|
|
|
|
| 116 |
st.markdown(s)
|
| 117 |
|
| 118 |
# add a button to advance the state
|
| 119 |
+
if st.button("I have looked over predictions and confirm correct species", icon= "👀",
|
| 120 |
+
type="primary",
|
| 121 |
+
help="Confirm that all species are selected correctly"):
|
| 122 |
st.session_state.workflow_fsm.complete_current_state()
|
| 123 |
# -> manual_inspection_completed
|
| 124 |
st.rerun()
|
|
|
|
| 130 |
st.markdown("""### Inference Results (after manual validation) """)
|
| 131 |
|
| 132 |
|
| 133 |
+
if st.button("Upload all observations to THE INTERNET!", icon= "⬆️",
|
| 134 |
+
type="primary",):
|
| 135 |
# let this go through to the push_all func, since it just reports to log for now.
|
| 136 |
push_all_observations(enable_push=False)
|
| 137 |
st.session_state.workflow_fsm.complete_current_state()
|
|
|
|
| 147 |
cetacean_show_results()
|
| 148 |
|
| 149 |
st.divider()
|
|
|
|
| 150 |
df = pd.DataFrame([obs.to_dict() for obs in st.session_state.observations.values()])
|
| 151 |
st.table(df)
|
| 152 |
|
src/utils/metadata_handler.py
CHANGED
|
@@ -14,7 +14,7 @@ def metadata2md(image_hash:str, debug:bool=False) -> str:
|
|
| 14 |
markdown_str = "\n"
|
| 15 |
keys_to_print = ["author_email", "latitude", "longitude", "date", "time"]
|
| 16 |
if debug:
|
| 17 |
-
keys_to_print += ["
|
| 18 |
|
| 19 |
observation = st.session_state.public_observations.get(image_hash, {})
|
| 20 |
|
|
|
|
| 14 |
markdown_str = "\n"
|
| 15 |
keys_to_print = ["author_email", "latitude", "longitude", "date", "time"]
|
| 16 |
if debug:
|
| 17 |
+
keys_to_print += ["image_md5", "selected_class", "top_prediction", "class_overriden"]
|
| 18 |
|
| 19 |
observation = st.session_state.public_observations.get(image_hash, {})
|
| 20 |
|