Spaces:
Running
Running
rmm
commited on
Commit
·
e3408e4
1
Parent(s):
6a146c8
doc: added short descriptions for each tab (in app, for user)
Browse files- src/main.py +21 -6
- src/obs_map.py +8 -1
- src/whale_gallery.py +5 -1
src/main.py
CHANGED
@@ -156,8 +156,9 @@ def main() -> None:
|
|
156 |
#g_logger.warning("warning message")
|
157 |
|
158 |
# Streamlit app
|
159 |
-
#tab_gallery, tab_inference, tab_hotdogs, tab_map,
|
160 |
-
tab_inference, tab_hotdogs, tab_map,
|
|
|
161 |
st.session_state.tab_log = tab_log
|
162 |
|
163 |
|
@@ -180,6 +181,7 @@ def main() -> None:
|
|
180 |
with tab_map:
|
181 |
# visual structure: a couple of toggles at the top, then the map inlcuding a
|
182 |
# dropdown for tileset selection.
|
|
|
183 |
tab_map_ui_cols = st.columns(2)
|
184 |
with tab_map_ui_cols[0]:
|
185 |
show_db_points = st.toggle("Show Points from DB", True)
|
@@ -208,9 +210,13 @@ def main() -> None:
|
|
208 |
|
209 |
|
210 |
|
211 |
-
with
|
212 |
# the goal of this tab is to allow selection of the new obsvation's location by map click/adjust.
|
213 |
-
st.markdown("Coming later
|
|
|
|
|
|
|
|
|
214 |
|
215 |
st.write("Click on the map to capture a location.")
|
216 |
#m = folium.Map(location=visp_loc, zoom_start=7)
|
@@ -248,7 +254,7 @@ def main() -> None:
|
|
248 |
tab_log.info(f"{st.session_state.full_data}")
|
249 |
|
250 |
df = pd.DataFrame(submitted_data, index=[0])
|
251 |
-
with
|
252 |
st.table(df)
|
253 |
|
254 |
|
@@ -260,12 +266,17 @@ def main() -> None:
|
|
260 |
# - these species are shown
|
261 |
# - the user can override the species prediction using the dropdown
|
262 |
# - an observation is uploaded if the user chooses.
|
|
|
|
|
|
|
|
|
263 |
|
264 |
if tab_inference.button("Identify with cetacean classifier"):
|
265 |
#pipe = pipeline("image-classification", model="Saving-Willy/cetacean-classifier", trust_remote_code=True)
|
266 |
cetacean_classifier = AutoModelForImageClassification.from_pretrained("Saving-Willy/cetacean-classifier",
|
267 |
revision=classifier_revision,
|
268 |
trust_remote_code=True)
|
|
|
269 |
|
270 |
if st.session_state.image is None:
|
271 |
# TODO: cleaner design to disable the button until data input done?
|
@@ -317,11 +328,15 @@ def main() -> None:
|
|
317 |
# purposes, an hotdog image classifier) which will be run locally.
|
318 |
# - this model predicts if the image is a hotdog or not, and returns probabilities
|
319 |
# - the input image is the same as for the ceteacean classifier - defined in the sidebar
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
if tab_hotdogs.button("Get Hotdog Prediction"):
|
322 |
|
323 |
pipeline_hot_dog = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
324 |
-
tab_hotdogs.title("Hot Dog? Or Not?")
|
325 |
|
326 |
if st.session_state.image is None:
|
327 |
st.info("Please upload an image first.")
|
|
|
156 |
#g_logger.warning("warning message")
|
157 |
|
158 |
# Streamlit app
|
159 |
+
#tab_gallery, tab_inference, tab_hotdogs, tab_map, tab_coords, tab_log = st.tabs(["Cetecean classifier", "Hotdog classifier", "Map", "Data", "Log", "Beautiful cetaceans"])
|
160 |
+
tab_inference, tab_hotdogs, tab_map, tab_coords, tab_log, tab_gallery = \
|
161 |
+
st.tabs(["Cetecean classifier", "Hotdog classifier", "Map", "*:gray[Dev:coordinates]*", "Log", "Beautiful cetaceans"])
|
162 |
st.session_state.tab_log = tab_log
|
163 |
|
164 |
|
|
|
181 |
with tab_map:
|
182 |
# visual structure: a couple of toggles at the top, then the map inlcuding a
|
183 |
# dropdown for tileset selection.
|
184 |
+
sw_map.add_header_text()
|
185 |
tab_map_ui_cols = st.columns(2)
|
186 |
with tab_map_ui_cols[0]:
|
187 |
show_db_points = st.toggle("Show Points from DB", True)
|
|
|
210 |
|
211 |
|
212 |
|
213 |
+
with tab_coords:
|
214 |
# the goal of this tab is to allow selection of the new obsvation's location by map click/adjust.
|
215 |
+
st.markdown("Coming later! :construction:")
|
216 |
+
st.markdown(
|
217 |
+
f"""*The goal is to allow interactive definition for the coordinates of a new
|
218 |
+
observation, by click/drag points on the map.*""")
|
219 |
+
|
220 |
|
221 |
st.write("Click on the map to capture a location.")
|
222 |
#m = folium.Map(location=visp_loc, zoom_start=7)
|
|
|
254 |
tab_log.info(f"{st.session_state.full_data}")
|
255 |
|
256 |
df = pd.DataFrame(submitted_data, index=[0])
|
257 |
+
with tab_coords:
|
258 |
st.table(df)
|
259 |
|
260 |
|
|
|
266 |
# - these species are shown
|
267 |
# - the user can override the species prediction using the dropdown
|
268 |
# - an observation is uploaded if the user chooses.
|
269 |
+
tab_inference.markdown("""
|
270 |
+
*Run classifer to identify the species of cetean on the uploaded image.
|
271 |
+
Once inference is complete, the top three predictions are shown.
|
272 |
+
You can override the prediction by selecting a species from the dropdown.*""")
|
273 |
|
274 |
if tab_inference.button("Identify with cetacean classifier"):
|
275 |
#pipe = pipeline("image-classification", model="Saving-Willy/cetacean-classifier", trust_remote_code=True)
|
276 |
cetacean_classifier = AutoModelForImageClassification.from_pretrained("Saving-Willy/cetacean-classifier",
|
277 |
revision=classifier_revision,
|
278 |
trust_remote_code=True)
|
279 |
+
|
280 |
|
281 |
if st.session_state.image is None:
|
282 |
# TODO: cleaner design to disable the button until data input done?
|
|
|
328 |
# purposes, an hotdog image classifier) which will be run locally.
|
329 |
# - this model predicts if the image is a hotdog or not, and returns probabilities
|
330 |
# - the input image is the same as for the ceteacean classifier - defined in the sidebar
|
331 |
+
tab_hotdogs.title("Hot Dog? Or Not?")
|
332 |
+
tab_hotdogs.write("""
|
333 |
+
*Run alternative classifer on input images. Here we are using
|
334 |
+
a binary classifier - hotdog or not - from
|
335 |
+
huggingface.co/julien-c/hotdog-not-hotdog.*""")
|
336 |
|
337 |
if tab_hotdogs.button("Get Hotdog Prediction"):
|
338 |
|
339 |
pipeline_hot_dog = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
|
|
340 |
|
341 |
if st.session_state.image is None:
|
342 |
st.info("Please upload an image first.")
|
src/obs_map.py
CHANGED
@@ -189,4 +189,11 @@ def present_obs_map(dataset_id:str = "Saving-Willy/Happywhale-kaggle",
|
|
189 |
# this is just debug info --
|
190 |
#st.info("[D]" + str(metadata.column_names))
|
191 |
|
192 |
-
return st_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
# this is just debug info --
|
190 |
#st.info("[D]" + str(metadata.column_names))
|
191 |
|
192 |
+
return st_data
|
193 |
+
|
194 |
+
|
195 |
+
def add_header_text() -> None:
|
196 |
+
"""
|
197 |
+
Add brief explainer text to the tab
|
198 |
+
"""
|
199 |
+
st.write("A map showing the observations in the dataset, with markers colored by species.")
|
src/whale_gallery.py
CHANGED
@@ -59,7 +59,11 @@ def render_whale_gallery(n_cols:int = 4) -> None:
|
|
59 |
""",
|
60 |
unsafe_allow_html=True,
|
61 |
)
|
62 |
-
|
|
|
|
|
|
|
|
|
63 |
cols = cycle(st.columns(n_cols))
|
64 |
for ix in range(len(sw_wv.df_whale_img_ref)):
|
65 |
img_name = sw_wv.df_whale_img_ref.iloc[ix].loc["WHALE_IMAGES"]
|
|
|
59 |
""",
|
60 |
unsafe_allow_html=True,
|
61 |
)
|
62 |
+
_n = len(sw_wv.df_whale_img_ref)
|
63 |
+
st.markdown(
|
64 |
+
f"""*The {_n} classes of cetaceans that our classifier can identify.
|
65 |
+
The links provide more information about each species, from NOAA or
|
66 |
+
wikipedia.*""")
|
67 |
cols = cycle(st.columns(n_cols))
|
68 |
for ix in range(len(sw_wv.df_whale_img_ref)):
|
69 |
img_name = sw_wv.df_whale_img_ref.iloc[ix].loc["WHALE_IMAGES"]
|