Spaces:
Running
Running
chore: update documentation to refactor
Browse files- docs/classifier_cetacean.md +3 -0
- docs/fix_tabrender.md +1 -1
- docs/grid_maker.md +3 -0
- docs/hf_push_observations.md +3 -0
- docs/hotdog.md +3 -0
- docs/input_handling.md +1 -1
- docs/input_observation.md +3 -0
- docs/input_validator.md +3 -0
- docs/metadata_handler.md +3 -0
- docs/obs_map.md +1 -1
- mkdocs.yaml +13 -2
- src/classifier/classifier_image.py +5 -0
- src/utils/grid_maker.py +8 -0
docs/classifier_cetacean.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
This module documents the cetacean fluke and fin classifier.
|
2 |
+
|
3 |
+
::: src.classifier.cetacean_image
|
docs/fix_tabrender.md
CHANGED
@@ -2,4 +2,4 @@ A js fix for certain UI elements, including maps, getting rendered into a
|
|
2 |
zero-sized frame by default. Here we resize it so it is visible once the tab is
|
3 |
clicked and no further interaction is required to see it.
|
4 |
|
5 |
-
::: src.fix_tabrender
|
|
|
2 |
zero-sized frame by default. Here we resize it so it is visible once the tab is
|
3 |
clicked and no further interaction is required to see it.
|
4 |
|
5 |
+
::: src.utils.fix_tabrender
|
docs/grid_maker.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
This module takes care of creating a grid composed of batches, rows and pages based on an incoming number of items.
|
2 |
+
|
3 |
+
::: src.utils.grid_maker
|
docs/hf_push_observations.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
This module writes an observation into a temporary JSON file, in order to add this JSON file to the Saving-Willy Dataset in the Saving-Willy Hugging Face Community.
|
2 |
+
|
3 |
+
::: src.hf_push_observations
|
docs/hotdog.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
This module documents the "hotdog" classifier. This example is purely a placeholder to show how multiple image (or other data) classifiers could be present in the same interface.
|
2 |
+
|
3 |
+
::: src.classifier.classifier_hotdog
|
docs/input_handling.md
CHANGED
@@ -5,4 +5,4 @@ This module focuses on image and metadata entry:
|
|
5 |
- a container class for an observation
|
6 |
|
7 |
|
8 |
-
::: src.input_handling
|
|
|
5 |
- a container class for an observation
|
6 |
|
7 |
|
8 |
+
::: src.input.input_handling
|
docs/input_observation.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
This module focuses on the Object Class representing an Observation once all the data has been extracted automatically or inputted by the user.
|
2 |
+
|
3 |
+
::: src.input.input_observation
|
docs/input_validator.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
This module focuses on the extraction and validation of data after data input.
|
2 |
+
|
3 |
+
::: src.input.input_validator
|
docs/metadata_handler.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
This module takes care of formatting some fields of the metadata to make them human readable by the user.
|
2 |
+
|
3 |
+
::: src.utils.metadata_handler
|
docs/obs_map.md
CHANGED
@@ -4,4 +4,4 @@ Note: OSM, ESRI, and CartoDB map tiles are served without authentication/tokens,
|
|
4 |
and so render correctly on the huggingface deployment. The Stamen tiles render
|
5 |
on localhost but require a token to present on a 3rd-party site.
|
6 |
|
7 |
-
::: src.obs_map
|
|
|
4 |
and so render correctly on the huggingface deployment. The Stamen tiles render
|
5 |
on localhost but require a token to present on a 3rd-party site.
|
6 |
|
7 |
+
::: src.maps.obs_map
|
mkdocs.yaml
CHANGED
@@ -28,12 +28,23 @@ nav:
|
|
28 |
- API:
|
29 |
- Main app: main.md
|
30 |
- Modules:
|
31 |
-
- Data entry handling:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
- Map of observations: obs_map.md
|
33 |
- Whale gallery: whale_gallery.md
|
34 |
- Whale viewer: whale_viewer.md
|
35 |
- Logging: st_logs.md
|
36 |
-
-
|
|
|
|
|
|
|
37 |
|
38 |
- Development clutter:
|
39 |
- Demo app: app.md
|
|
|
28 |
- API:
|
29 |
- Main app: main.md
|
30 |
- Modules:
|
31 |
+
- Data entry handling:
|
32 |
+
- Data input: input_handling.md
|
33 |
+
- Data extraction and validation: input_validator.md
|
34 |
+
- Data Object Class: input_observation.md
|
35 |
+
- Classifiers:
|
36 |
+
- Cetacean Fluke & Fin Recognition: classifier_cetacean.md
|
37 |
+
- (temporary) Hotdog Classifier: hotdog.md
|
38 |
+
- Hugging Face Integration:
|
39 |
+
- Push Observations to Dataset: hf_push_observations.md
|
40 |
- Map of observations: obs_map.md
|
41 |
- Whale gallery: whale_gallery.md
|
42 |
- Whale viewer: whale_viewer.md
|
43 |
- Logging: st_logs.md
|
44 |
+
- Utils:
|
45 |
+
- Tab-rendering fix (js): fix_tabrender.md
|
46 |
+
- Metadata handling: metadata_handler.md
|
47 |
+
- Grid maker: grid_maker.md
|
48 |
|
49 |
- Development clutter:
|
50 |
- Demo app: app.md
|
src/classifier/classifier_image.py
CHANGED
@@ -12,6 +12,11 @@ from utils.grid_maker import gridder
|
|
12 |
from utils.metadata_handler import metadata2md
|
13 |
|
14 |
def cetacean_classify(cetacean_classifier):
|
|
|
|
|
|
|
|
|
|
|
15 |
images = st.session_state.images
|
16 |
observations = st.session_state.observations
|
17 |
hashes = st.session_state.image_hashes
|
|
|
12 |
from utils.metadata_handler import metadata2md
|
13 |
|
14 |
def cetacean_classify(cetacean_classifier):
|
15 |
+
"""Cetacean classifier using the saving-willy model from Saving Willy Hugging Face space.
|
16 |
+
For each image in the session state, classify the image and display the top 3 predictions.
|
17 |
+
Args:
|
18 |
+
cetacean_classifier ([type]): saving-willy model from Saving Willy Hugging Face space
|
19 |
+
"""
|
20 |
images = st.session_state.images
|
21 |
observations = st.session_state.observations
|
22 |
hashes = st.session_state.image_hashes
|
src/utils/grid_maker.py
CHANGED
@@ -2,6 +2,14 @@ import streamlit as st
|
|
2 |
import math
|
3 |
|
4 |
def gridder(items):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
cols = st.columns(3)
|
6 |
with cols[0]:
|
7 |
batch_size = st.select_slider("Batch size:",range(10,110,10), value=10)
|
|
|
2 |
import math
|
3 |
|
4 |
def gridder(items):
|
5 |
+
"""Creates a grid for displaying items in a batched manner.
|
6 |
+
Args:
|
7 |
+
items (list): The items to be displayed.
|
8 |
+
Returns:
|
9 |
+
batch_size (int): The number of items to display in each batch.
|
10 |
+
row_size (int): The number of items to display in each row.
|
11 |
+
page (int): The range of pages available based on the number of items.
|
12 |
+
"""
|
13 |
cols = st.columns(3)
|
14 |
with cols[0]:
|
15 |
batch_size = st.select_slider("Batch size:",range(10,110,10), value=10)
|