Docs: standalone snippets, install requirements, statistics
Browse files133 unmodified lines13413513613713813914014114214314414514614714820 unmodified lines16917017117217317417517617717817918018118218318418518615 unmodified lines2022032042052062072082092102112126 unmodified lines2192202212222232244 unmodified lines2292302312322332343 unmodified lines23823924024124224311 unmodified lines25525625725825926062 unmodified lines32332432532632732832942 unmodified lines37237337437537637737837938038175 unmodified lines457458459460461462463464133 unmodified linesprint(row["licence"], row["attribution"])```Scripts and training: download the config once, cached afterwards (all splits are fetched; the full `coral-masks` config is about 12 GB).```pythonds = load_dataset("reefsupport/marine-data", "coral-masks", split="train")```One source only: download just that source's shards (file names are `<split>-<source>-<n>-of-<total>.parquet`).```pythonds = load_dataset("reefsupport/marine-data","coral-masks",20 unmodified linesBoxes in `fish-boxes` are normalised to 0-1:```pythonstream = load_dataset("reefsupport/marine-data", "fish-boxes", split="train", streaming=True)row = next(iter(stream))print(row["boxes"][0]) # {"x_min": .., "y_min": .., "x_max": .., "y_max": .., "label": "fish"}```Select one source inside a configuration: `ds.filter(lambda r: r["source"] == "coralscapes")`.## Label mappingThe masks keep the native ids of each source, and those ids differ between sources, so `marinedata.labels` maps every source onto one of three shared schemes with fixed class ids. 255 is the ignore value in every scheme and, for partially annotated sources, it means "not annotated" rather than background, so mask the loss to `labels.supervised_classes(source, scheme)` for those sources.The `marinedata` package is not published on PyPI. Install the tagged release; the `hf` extra adds `datasets` and Pillow:```bashpip install "marinedata[hf] @ git+https://github.com/reefsupport/marine-data@v1.0.0"15 unmodified linesIn a script, download the config or one source as described under [Quick start](#quick-start) and pass its rows to `remap_row` the same way:```pythonds = load_dataset("reefsupport/marine-data", "scene-masks", split="train")row = labels.remap_row(ds[0], "scene")``````pythonds = load_dataset("reefsupport/marine-data","coral-masks",6 unmodified linesThe other configurations use the `scene` scheme. `scene-masks` rows work with `remap_row` as above:```pythonstream = load_dataset("reefsupport/marine-data", "scene-masks", split="train", streaming=True)row = labels.remap_row(next(iter(stream)), "scene")names = labels.class_names("scene")4 unmodified lines`instance-masks` rows carry a list of `instances` instead of one semantic mask, so map each instance label with `labels.map_label` (it returns `None` for a label the scheme does not cover):```pythonstream = load_dataset("reefsupport/marine-data", "instance-masks", split="train", streaming=True)row = next(iter(stream))ids = [labels.map_label(row["source"], inst["label_native"], "scene") for inst in row["instances"]]3 unmodified lines`fish-boxes` rows have `boxes` and name their source in `source_id`:```pythonstream = load_dataset("reefsupport/marine-data", "fish-boxes", split="train", streaming=True)row = next(iter(stream))ids = [labels.map_label(row["source_id"], box["label"], "scene") for box in row["boxes"]]11 unmodified lines**Label policy.** The schemes are set up for training on several sources at once. Dead coral is ignored by default: in `benthic-coarse` and `coral-binary`, a label whose condition is dead goes to 255 (the five dead coral classes of Coralscapes, and `dead clam`), because Coralscapes separates alive, dead and bleached coral while the Reef Support and Seaview masks record no condition. Bleached coral is alive and stays `HC` / `CORAL`. The Coralscapes class `unknown hard substrate` mixes rock with octocorals and is ignored in both schemes. A few Coralscapes labels the registry leaves open are mapped: `sponge` and `anemone` to `OTHER_FAUNA`, `algae covered substrate` to `ALGAE`. To opt out of the dead-coral default, pass `exclude_conditions=()`; `("bleached",)` ignores bleached coral but keeps dead coral:```pythontable = labels.lut("coralscapes", "benthic-coarse", exclude_conditions=()) # dead coral is HC again```62 unmodified lines<p align="center"><img src="assets/preview-fish-boxes.png" alt="Preview of the fish-boxes configuration"></p>Fish and fauna photos with bounding boxes (`x_min`, `y_min`, `x_max`, `y_max` normalised to 0-1, native `label`). 25,912images at 640x480 with about 2.7 boxes per image. For the UIIS-family sources the boxes are derived from the upstreaminstance annotations, one box per instance. Labels are the upstream vocabularies (for example `fish`, `corals`, `reefs`,`jellyfish`, `human divers`). The build ran a deduplication gate: no image spans two splits, and no upstream test imageis in train.42 unmodified lines| `upstream_id`, `upstream_url`, `lat`, `lon`, `depth_m`, `meow_realm`, `habitat` | mixed | Optional context; null unless the source provides it. || `width`, `height` | int | Pixel size. |Note on the Seaview rows: in this release the `licence` and `attribution` values of `reef-support-seaview-labels` rowsread `CC-BY-3.0-AU` for the images. The licence stated for those images by the University of Queensland record isCC BY 3.0 (unported), as given in [Licensing](#licensing), and the statement in this card and in `docs/coral-masks/`takes precedence over the column.## Dataset creation75 unmodified lines**Seaview images.** The University of Queensland record for the Seaview Survey dataset (UQ eSpace UQ:734799) states thelicence as Creative Commons Attribution 3.0 International (CC BY 3.0). The Seaview rows of thisrelease read `CC-BY-3.0-AU` in their `licence` and `attribution` columns; the licence stated by the University ofQueensland, CC BY 3.0, applies.## Citation133 unmodified lines13413513613713813914014114214314414514614714814915015115220 unmodified lines17317417517617717817918018118218318418518618718818919019119215 unmodified lines2082092102112122132142152162172182192202212222232246 unmodified lines2312322332342352362372382394 unmodified lines2442452462472482492502512523 unmodified lines25625725825926026126226326411 unmodified lines27627727827928028128228362 unmodified lines34634734834935035135242 unmodified lines39539639739839940040140240340475 unmodified lines480481482483484485486487133 unmodified linesprint(row["licence"], row["attribution"])```Scripts and training: download the config once, cached afterwards. `coral-masks` is 12.6 GB (all splits are fetched); to try the pipeline first, use `scene-masks` (0.2 GB) or the one-source form below.```pythonfrom datasets import load_datasetds = load_dataset("reefsupport/marine-data", "coral-masks", split="train")```One source only: download just that source's shards (file names are `<split>-<source>-<n>-of-<total>.parquet`).```pythonfrom datasets import load_datasetds = load_dataset("reefsupport/marine-data","coral-masks",20 unmodified linesBoxes in `fish-boxes` are normalised to 0-1:```pythonfrom datasets import load_datasetstream = load_dataset("reefsupport/marine-data", "fish-boxes", split="train", streaming=True)row = next(iter(stream))print(row["boxes"][0]) # {"x_min": .., "y_min": .., "x_max": .., "y_max": .., "label": "fish"}```Select one source inside a configuration: `ds.filter(lambda s: s == "coralscapes", input_columns="source")`.## Label mappingThe masks keep the native ids of each source, and those ids differ between sources, so `marinedata.labels` maps every source onto one of three shared schemes with fixed class ids. 255 is the ignore value in every scheme and, for partially annotated sources, it means "not annotated" rather than background, so mask the loss to `labels.supervised_classes(source, scheme)` for those sources.Requires Python 3.10 or newer and git. The package is not on PyPI; install the tagged release. The `hf` extra adds `datasets` and Pillow:```bashpip install "marinedata[hf] @ git+https://github.com/reefsupport/marine-data@v1.0.0"15 unmodified linesIn a script, download the config or one source as described under [Quick start](#quick-start) and pass its rows to `remap_row` the same way:```pythonfrom datasets import load_datasetfrom marinedata import labelsds = load_dataset("reefsupport/marine-data", "scene-masks", split="train")row = labels.remap_row(ds[0], "scene")``````pythonfrom datasets import load_datasetfrom marinedata import labelsds = load_dataset("reefsupport/marine-data","coral-masks",6 unmodified linesThe other configurations use the `scene` scheme. `scene-masks` rows work with `remap_row` as above:```pythonfrom datasets import load_datasetfrom marinedata import labelsstream = load_dataset("reefsupport/marine-data", "scene-masks", split="train", streaming=True)row = labels.remap_row(next(iter(stream)), "scene")names = labels.class_names("scene")4 unmodified lines`instance-masks` rows carry a list of `instances` instead of one semantic mask, so map each instance label with `labels.map_label` (it returns `None` for a label the scheme does not cover):```pythonfrom datasets import load_datasetfrom marinedata import labelsstream = load_dataset("reefsupport/marine-data", "instance-masks", split="train", streaming=True)row = next(iter(stream))ids = [labels.map_label(row["source"], inst["label_native"], "scene") for inst in row["instances"]]3 unmodified lines`fish-boxes` rows have `boxes` and name their source in `source_id`:```pythonfrom datasets import load_datasetfrom marinedata import labelsstream = load_dataset("reefsupport/marine-data", "fish-boxes", split="train", streaming=True)row = next(iter(stream))ids = [labels.map_label(row["source_id"], box["label"], "scene") for box in row["boxes"]]11 unmodified lines**Label policy.** The schemes are set up for training on several sources at once. Dead coral is ignored by default: in `benthic-coarse` and `coral-binary`, a label whose condition is dead goes to 255 (the five dead coral classes of Coralscapes, and `dead clam`), because Coralscapes separates alive, dead and bleached coral while the Reef Support and Seaview masks record no condition. Bleached coral is alive and stays `HC` / `CORAL`. The Coralscapes class `unknown hard substrate` mixes rock with octocorals and is ignored in both schemes. A few Coralscapes labels the registry leaves open are mapped: `sponge` and `anemone` to `OTHER_FAUNA`, `algae covered substrate` to `ALGAE`. To opt out of the dead-coral default, pass `exclude_conditions=()`; `("bleached",)` ignores bleached coral but keeps dead coral:```pythonfrom marinedata import labelstable = labels.lut("coralscapes", "benthic-coarse", exclude_conditions=()) # dead coral is HC again```62 unmodified lines<p align="center"><img src="assets/preview-fish-boxes.png" alt="Preview of the fish-boxes configuration"></p>Fish and fauna photos with bounding boxes (`x_min`, `y_min`, `x_max`, `y_max` normalised to 0-1, native `label`). 25,912images (mostly 640x480; sizes vary) with about 3.6 boxes per image (1.8 for usis10k, 7.6 for roboflow-aquarium). For the UIIS-family sources the boxes are derived from the upstreaminstance annotations, one box per instance. Labels are the upstream vocabularies (for example `fish`, `corals`, `reefs`,`jellyfish`, `human divers`). The build ran a deduplication gate: no image spans two splits, and no upstream test imageis in train.42 unmodified lines| `upstream_id`, `upstream_url`, `lat`, `lon`, `depth_m`, `meow_realm`, `habitat` | mixed | Optional context; null unless the source provides it. || `width`, `height` | int | Pixel size. |Note on the Seaview rows: the `licence` column of `reef-support-seaview-labels` rows reads exactly`CC-BY-3.0-AU (images); CC-BY-4.0 (masks, Reef Support)`, and the `attribution` column cites `CC-BY-3.0-AU` for the images.The images are CC BY 3.0 (unported), as stated by the University of Queensland, and the attribution in the[Licensing](#licensing) table is the one to reproduce.## Dataset creation75 unmodified lines**Seaview images.** The University of Queensland record for the Seaview Survey dataset (UQ eSpace UQ:734799) states thelicence as Creative Commons Attribution 3.0 International (CC BY 3.0). The Seaview rows of thisrelease read `CC-BY-3.0-AU (images); CC-BY-4.0 (masks, Reef Support)` in their `licence` column, and `CC-BY-3.0-AU` in their `attribution` column for the images. The images are CC BY 3.0(unported) as stated by the University of Queensland, and the attribution in the table above is the one to reproduce.## Citation
README.md+33-10