File size: 21,131 Bytes
e5a54db
 
 
a940a7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e5a54db
a940a7c
150f923
a940a7c
150f923
a940a7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150f923
 
8af2e1d
 
32f87ad
8af2e1d
31d67c3
150f923
31d67c3
a940a7c
31d67c3
a940a7c
 
150f923
a940a7c
 
 
 
 
 
8af2e1d
 
 
 
 
 
 
a940a7c
8af2e1d
 
 
 
a940a7c
32f87ad
8af2e1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a940a7c
150f923
 
31d67c3
 
5260e84
 
8af2e1d
31d67c3
 
150f923
31d67c3
a940a7c
 
150f923
5260e84
150f923
a940a7c
150f923
a940a7c
ba08ee6
31d67c3
ba08ee6
a940a7c
ba08ee6
 
a940a7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
---
language:
- en
pretty_name: TreeOfLife-10M Exploratory Data Analysis
description: >-
  Real-time exploratory data analysis of the TreeOfLife-10M and Rare Species
  datasets during their creation and refinement. It is not intended for re-use
  as a dataset, but is shared in the spirit of open-science to provide further
  insight into the creation of the TreeOfLife-10M dataset and the Rare Species
  benchmark.
tags:
- EDA
- imageomics
- biology
- rare-species
- plants
- animals
- fungi
- reference
viewer: false
---
# TreeOfLife-10M EDA Repo

This repo contains the real-time exploratory data analysis of the [TreeOfLife-10M](https://huggingface.co/datasets/imageomics/TreeOfLife-10M) and [Rare Species](https://huggingface.co/datasets/imageomics/rare-species) datasets during their creation and refinement. It is not intended for re-use as a dataset, but is shared in the spirit of open-science to provide further insight into the creation of the TreeOfLife-10M dataset and the Rare Species benchmark.

## Dataset Details

### Dataset Description

- **Curated by:** Elizabeth G. Campolongo and Matthew J. Thompson
- **Homepage:** [BioCLIP Project Page](https://imageomics.github.io/bioclip/)
- **Repository:** [BioCLIP project repo](https://github.com/Imageomics/BioCLIP)
- **Paper:** [BioCLIP: A Vision Foundation Model for the Tree of Life](https://arxiv.org/abs/2311.18803)


## Dataset Structure

As noted above, this dataset consists primarily of the exploratory data analysis during creation of the [TreeOfLife-10M](https://huggingface.co/datasets/imageomics/TreeOfLife-10M) and [Rare Species](https://huggingface.co/datasets/imageomics/rare-species) datasets. More detailed descriptions of its contents are provided below.

```
data/
    taxa_files/
        sample_images/
            20507360_64639770_eol-full-size-copy.jpg
            22255430_64639830_eol-full-size-copy.jpg
            29906970_65415246_eol-full-size-copy.jpg
            29907020_65415246_eol-full-size-copy.jpg
            30038365_65415248_eol-full-size-copy.jpg
            8757019_49951271_eol-full-size-copy.jpg
            8757071_49951271_eol-full-size-copy.jpg
            8757093_49951271_eol-full-size-copy.jpg
            8757102_49951271_eol-full-size-copy.jpg
            8791997_49952170_eol-full-size-copy.jpg
            8792002_49952170_eol-full-size-copy.jpg
            8922943_49955771_eol-full-size-copy.jpg
        ToL_hybrids_Arthropoda.csv
        sample_arthropoda_mislabels.txt
        README.md    # Hemihomonym description and explanation
    avg_std_byClass.csv
    catalog-v1-dev.csv
    catalog.csv
    licenses.csv
    missing_taxa_output.txt
    predicted-catalog.csv
    stats_avg_std_byClass.csv
    taxa_counts.csv
    tol_hierarchy_test.csv
eol_realign/
    data/
        checksums_media_cargo_archive.csv
        combined-manifest-licenses.csv
        combined_manifest.csv
        combined_manifest_with_checksums.csv
        eol-cargo-archive_catalog_combined-manifest-checksums_links.csv
        eol-cargo-archive_combined-manifest-checksums_links.csv
        full_owner_manifest.csv
        links_cargo_manifest_IDmismatch.csv
        links_inner.csv
        links_manifest_cargo_on_md5.csv
        mismatched_rarespecies.csv
        rarespecies_full_manifest.csv
        rs_links.csv
    notebooks/
        catalog-cargo-manifest_test.ipynb
        links_align_reduced.ipynb
        links_align_reduced.py
        links_rs_duplicates.ipynb
        links_rs_duplicates.py
        re-gen_rs_catalog.ipynb
        re-gen_tol_catalog.ipynb
    scripts/
        make_licenses.py
        match_owners.py
notebooks/
    BioCLIP_data_viz.ipynb
    BioCLIP_taxa_viz.ipynb
    BioCLIP_taxa_viz.py
    BioCLIP_taxa_viz_bySource.ipynb
    ToL_EDA.ipynb
    ToL_catalog_EDA.ipynb
    ToL_catalog_EDA.py
    ToL_predicted-catalog_EDA.ipynb
    ToL_predicted-catalog_EDA.py
    make_ToL_hybrids_Arthropoda_EDA.ipynb
    missing_taxa_testGen.ipynb
rare_species/
    data/
        licenses.csv
        rarespecies-catalog.csv
        rarespecies_manifest.csv
visuals/
    category-v1-visuals/    # "catalog v1" visualizations, don't match published dataset
    kingdom_ToL_tree.html
    kingdom_ToL_tree.pdf
    phyla_ToL_tree.html
    phyla_ToL_tree.pdf
requirements.txt    # installation of these packages is sufficient for all code (notebooks & scripts) in this repo
```


### Data

The `data` folder contains
 - `catalog.csv`: the metadata and identifiers for all images in the dataset. This includes original data source, unique identifier within TreeOfLife10M, and the associated taxa information for the image. This is the file that will be updated, while preserving the `catalog-v1-dev.csv` file for ease of comparison. [`v3.3`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/d6b583841aed8c0df314e718735756b76164a933/data/catalog.csv) is the version of the catalog that was used for training [BioCLIP v1](https://doi.org/10.57967/hf/1511) (it has the ~30K images we could not re-align).
 - `stats_avg_std_byClass.csv`: average and standard distribution of images given by class in `catalog.csv`. This is for both all 
images, and images that have labels.
 - `predicted-catalog.csv`: the metadata and identifiers for all entries expected in the dataset, prior to webdataset creation. This includes original data source, unique identifier within TreeOfLife10M, and the associated taxa information. In version 3.3 (first time it was generated), it showed 27K more entries than in the webdataset and they all had full taxonomic rank filled.
 - `catalog-v1-dev.csv`: the metadata and identifiers for all images in the dataset. This includes original data source, unique identifier within TreeOfLife10M, and the associated taxa information for the image. This file will be maintained for v1 reference, and as such will not be updated.
 - `taxa_counts.csv`: count of distinct lower taxa within each higher taxon from `kingdom` down to 
`genus` in `catalog-v1-dev.csv`, though the genus count was interrupted and therefore is incomplete.
 - `missing_taxa_output.txt`: output from the [check taxa script](https://github.com/Imageomics/bioclip/blob/main/scripts/evobio10m/check_taxa.py), record of versions of catalog checked are indicated before the printout (text was copied from the terminal).
 - `avg_std_byClass.csv`: average and standard distribution of images in `catalog-v1-dev.csv` given by class (taxonomic rank). This is for both all images, and images that have labels. Note that kingdoms had not been merged and no standardization was performed on the taxonomic hierarchy prior to creation of this file.
 - `tol_hierarchy_test.csv`: Subset of `catalog-v1-dev.csv` for testing the [`check_taxa` script](https://github.com/Imageomics/bioclip/blob/main/scripts/evobio10m/check_taxa.py) to ensure the hierarchy is properly filled in after data generation.
 - `licenses.csv`: licensing information for all images in the catalog. This should match the published [licenses.csv](https://huggingface.co/datasets/imageomics/TreeOfLife-10M/blob/main/metadata/licenses.csv) (SHA256 match), described in the [metadata section of the TreeOfLife-10M Dataset Card](https://huggingface.co/datasets/imageomics/TreeOfLife-10M#metadata-files).

#### Taxa Files

This subfolder of `data/` explores instances of hemihomonyms (taxa in different kingdoms with matching Genus-species) in the dataset. One thought is that this may be part of the reason we had so many misclassifications into _Arthropoda_. 
There is a notebook that partially explores this (`notebooks/make_ToL_hybrids_Arthropoda_EDA.ipynb`) and two associated files (`data/taxa_files/ToL_hybrids_Arthropoda.csv` and `data/taxa_files/sample_arthropoda_mislabels.txt` which is a list of filenames for the sample images in `data/taxa_files/sample_images/`). More details are provided in the [taxa_files README](https://huggingface.co/datasets/imageomics/ToL-EDA/tree/main/taxa_files/README.md). This discovery lead to the re-resolution of the TreeOfLife-10M taxonomy from the original published dataset ([TreeOfLife-10M (Revision 69ca82e), DOI: 10.57967/hf/1972](https://huggingface.co/datasets/imageomics/TreeOfLife-10M/tree/69ca82e7481dcae0764f7c5452ea32b3a41cf620), the reproducibility + embeddings update to the original is [Revision ffa2a31, DOI: 10.57967/hf/7542](https://huggingface.co/datasets/imageomics/TreeOfLife-10M/tree/ffa2a318a1396f2f9e456ba171d3b5b5d8b4f051)).

### Rare Species 
All these files were generated in `eol_realign/notebooks/re-gen_rs_catalog.ipynb`.
 - `licenses.csv`: Licensing information for all rarespecies images (includes MD5s and links to catalog and manifest on `rarespecies_id`).
 - `rarespecies_manifest.csv`: Full manifest information for all images included in rarespecies catalog (may have some extra info from realign).
 - `rarespecies-catalog.csv`: Catalog of all images included in [Rare Species dataset](https://huggingface.co/imageomics/rare-species).
For evaluation, Lisa generated a `metadata.csv` that cut the `rarespecies-catalog.csv` down to just the taxonomic columns with index, changing `class` to `cls`, `common` to `common_name`, and creating a `filepath` column (`"2024-03-20/" + <eol_content_id> + "_" + <eol_page_id> + "_eol-full-size-copy.jpg"`), with a `class` column indicating the `sciName` (though this could use a different ID depending on the evaluation).


### EOL Re-align

  More detail on the background of this process can be found in the `links_align_reduced` and `links_rs_duplicates` notebooks, as well as [PR #5](https://huggingface.co/datasets/imageomics/ToL-EDA/discussions/5).
  
 * **Data:**
    More information on all the data can be found in the `links_align_reduced` and `links_rs_duplicates` notebooks. Just those of primary import and potential continued use are listed here.

    - `checksums_media_cargo_archive.csv`: MD5 of all EOL images in our cargo archive.
    - `full_owner_manifset.csv`: Record of all images from EOL that could potentially be used in the TreeOfLife-10M dataset, this has all the non-taxonomic EOL metadata for the EOL images included in the TreeOfLife-10M catalog (12,330,062 entries, gets reduced down during catalog re-generation), with MD5s aligned to `filename` (`<eol_content_id>_<eol_page_id>_eol-full-size-copy.jpg`).
    - `rarespecies_full_manifest.csv`: Record of all images from EOL that could potentially be used in the Rare Species dataset, i.e., manifest of all images from EOL of the 400 selected species, with MD5s aligned to `filename` (`<eol_content_id>_<eol_page_id>_eol-full-size-copy.jpg`). 

 * **Notebooks:** (Require `pandas`).
  
     - `catalog-cargo-manifest_test.ipynb`: Generates `eol_realign/data/full_owner_manifest.csv`, this has all the non-taxonomic EOL metadata for the EOL images included in the TreeOfLife-10M catalog (12,330,062 entries, gets reduced down during catalog re-generation).
     - `links_align_reduced.ipynb`: Exploration of the degree to which we could realign the EOL files in our TreeOfLife-10M catalog to their associated metadata. There was some recovery from our original loss. Associated `py` file: `links_align_reduced.py`.
     - `links_rs_duplicates.ipynb`: Documentation of mismatches in the Rare Species dataset and suggestion for fixing them. Saves these in `eol_realign/data/archive_mismatched_rarespecies.csv`, and generates `eol_realign/data/rarespecies_full_manifest.csv`. Uses `eol_realign/data/eol-cargo-archive_combined-manifest-checksums_links.csv`, [`rarespecies-catalog-orig.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/5db838a9db980f4cf96027b326b06e0f42df0c65/rare_species/data/rarespecies-catalog.csv), `eol_realign/data/rarespecies_missing_pages_md5s.csv`, `eol_realign/data/eol_media_manifest_2024-03-11.csv`, and [`media_manifest_missing_licenses_jul26_owners.csv`](https://huggingface.co/datasets/imageomics/eol/blob/main/owners_info_fix/media_manifest_missing_licenses_jul26_owners.csv). Associated `py` file: `links_rs_duplicates.py`.
     - `re-gen_rs_catalog.ipynb`: Notebook generating the updated rare species catalog, lisences, and manifest files. Generates new `rarespecies_id`; these are still distinct from `treeoflife_id`s in TreeOfLife-10M. Uses `eol_realign/data/rarespecies_full_manifest.csv`and [`rarespecies-catalog-orig.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/5db838a9db980f4cf96027b326b06e0f42df0c65/rare_species/data/rarespecies-catalog.csv).
    Outputs: `rare_species/data/rarespecies_manifest.csv`, `rare_species/data/licenses.csv`, and `rare_species/data/rarespecies-catalog.csv`.
     - `re-gen_tol_catalog.ipynb`: Notebook updating catalog for TreeOfLife-10M (all EOL entries we could realign), along with the corresponding license file, and manifest with full information for the realigned entries. Uses `eol_realign/data/combined-manifest-licenses.csv`, [`catalog-orig-v3-3.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/d6b583841aed8c0df314e718735756b76164a933/data/catalog.csv).
    Outputs: `eol_realign/data/full_owner_manifest.csv`, `data/licenses.csv`, and `data/catalog.csv`.

 * **Scripts:** (Require `pandas`).
    
     - `make_licenses.py`: Adds license URLs to make the full manifest and license file.
     - `match_owners.py`: Adds extra licensing information toward making the full manifest. Uses `eol_realign/data/eol-cargo-archive_catalog_combined-manifest-checksums_links.csv`, makes `eol_realign/data/combined_manifest.csv` for generating final catalog.

### Notebooks

The `notebooks` folder contains
 - `ToL_catalog_EDA.ipynb`: more full EDA of TreeOfLife10M dataset using `catalog.csv`. To be updated as `catalog.csv` is updated, i.e., as the dataset is updated.
 - `ToL_catalog_EDA.py`: py file paired to `ToL_catalog_EDA.ipynb` to facilitate diff checking in case of cell text changes in notebook.
 - `ToL_predicted-catalog_EDA.ipynb`: more full EDA of TreeOfLife10M dataset using `predicted-catalog.csv`. To be updated as `predicted-catalog.csv` is updated, i.e., as the dataset is updated.
 - `ToL_predicted-catalog_EDA.py`: py file paired to `ToL_predicted-catalog_EDA.ipynb` to facilitate diff checking in case of cell text changes in notebook.
 - `BioCLIP_taxa_viz.ipynb`: generates data visualizations, in particular, the generation of treemaps in `visuals` folder; also includes a histogram of kingdoms. The treemaps produced in the notebook are interactive and `HTML` interactive versions can also be found in [`visuals`](https://huggingface.co/datasets/imageomics/ToL-EDA/tree/main/visuals).
 - `BioCLIP_data_viz.ipynb`: notebook with quick basic stats for `catalog-v1-dev.csv`, generates `taxa_counts.csv`.
 - `BioCLIP_taxa_viz_bySource.ipynb`: generates data visualizations, in particular, the generation of visualizations in `visuals` folder and some histograms. The treemaps produced in the notebook are interactive.
 - `ToL_EDA.ipynb`: more full EDA of TreeOfLife10M dataset. Explores the labeling inconsistencies for 
direction of standardization efforts. Maintained for v1 reference, should not be updated.
 - `make_ToL_hybrids_Arthropoda_EDA.ipynb`:
 - `missing_taxa_testGen.ipynb`: generates `tol_hierarchy_test.csv` to test [`check_taxa` script](https://github.com/Imageomics/bioclip/blob/main/scripts/evobio10m/check_taxa.py). Also observes species labeled as `(unidentified)` in EOL data.

**Note:** run `pip install -r requirements.txt` before starting the visualization notebooks. EDA notebooks only require `pandas` and `seaborn`.

### Visuals

Visualizations generated to demonstrate the distribution and diversity within the phyla of TreeOfLife10M. These were created using the [`taxa_viz` script](https://github.com/Imageomics/bioclip/blob/main/scripts/evobio10m/taxa_viz.py).
- `category-v1-visuals`: visualizations made for the original `catalog-v1-dev.csv` using `BioCLIP_taxa_viz_bySource.ipynb`.
There is also one for just the iNat21 data included.
- `kingdom_ToL_tree.html`: interactive treemap from `kingdom` to `family` to demonstrate the distribution of the data. 2:1 aspect ratio.
- `kingdom_ToL_tree.pdf`: static treemap from `kingdom` to `family` to demonstrate the distribution of the data. 2:1 aspect ratio.
- `phyla_ToL_tree.html`: interactive treemap from `phylum` to `family` to demonstrate the distribution of the data. 2:1 aspect ratio.
- `kingdom_ToL_tree.pdf`: static treemap from `phylum` to `family` to demonstrate the distribution of the data. 2:1 aspect ratio.


## Licensing Information

The images shared in this repository (`data/taxa_files/sample_images/`) are shared under their original licenses as indicated in [`data/taxa_files/metadata.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/tree/main/data/taxa_files/metadata.csv).

The code in this repository is shared under an [MIT license](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/main/LICENSE.md).

For more information on the dataset licensing and that of images mentioned or referenced throughout this repository, please see the [TreeOfLife-10M](https://huggingface.co/datasets/imageomics/TreeOfLife-10M) license files. The data (images and text) contain a variety of licensing restrictions mostly within the CC family. Each image and text in this dataset is provided under the least restrictive terms allowed by its licensing requirements as provided to us (i.e, we impose no additional restrictions past those specified by licenses in the license file).

Please see the [iNat21 terms of use](https://github.com/visipedia/inat_comp/tree/master/2021#terms-of-use) for full information on use of their images.

All BIOSCAN-1M images are licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).

EOL images contain a variety of licenses ranging from [CC0](https://creativecommons.org/publicdomain/zero/1.0/) to [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/4.0/). For license and citation information by image, see the associated license files.

## Acknowledgements

This work was supported by the [Imageomics Institute](https://imageomics.org), which is funded by the US National Science Foundation's Harnessing the Data Revolution (HDR) program under [Award #2118240](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2118240) (Imageomics: A New Frontier of Biological Information Powered by Knowledge-Guided Machine Learning). Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

## Citation

As noted in the description of this dataset, it is not a finished product intended for re-use, but is provided in as an act of open-science. If the exploration or scripts are re-used, please cite our paper: 
```
@inproceedings{stevens2024bioclip,
  title = {{B}io{CLIP}: A Vision Foundation Model for the Tree of Life}, 
  author = {Samuel Stevens and Jiaman Wu and Matthew J Thompson and Elizabeth G Campolongo and Chan Hee Song and David Edward Carlyn and Li Dong and Wasila M Dahdul and Charles Stewart and Tanya Berger-Wolf and Wei-Lun Chao and Yu Su},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year = {2024},
  pages = {19412-19424}
}
```

See also the citation instructions for [TreeOfLife-10M](https://huggingface.co/datasets/imageomics/TreeOfLife-10M#citation-information) and the [Rare Species Benchmark](https://huggingface.co/datasets/imageomics/rare-species), and please be sure to also cite the original data sources and all constituent parts as appropriate.

- iNat21:
```
@misc{inat2021,
  author={Van Horn, Grant and Mac Aodha, Oisin},
  title={iNat Challenge 2021 - FGVC8},
  publisher={Kaggle},
  year={2021},
  url={https://kaggle.com/competitions/inaturalist-2021}
}
```
- BIOSCAN-1M:
```
@inproceedings{gharaee2023step,
    title={A Step Towards Worldwide Biodiversity Assessment: The {BIOSCAN-1M} Insect Dataset},
    booktitle = {Advances in Neural Information Processing Systems ({NeurIPS}) Datasets \& Benchmarks Track},
    author={Gharaee, Z. and Gong, Z. and Pellegrino, N. and Zarubiieva, I. and Haurum, J. B. and Lowe, S. C. and McKeown, J. T. A. and Ho, C. Y. and McLeod, J. and Wei, Y. C. and Agda, J. and Ratnasingham, S. and Steinke, D. and Chang, A. X. and Taylor, G. W. and Fieguth, P.},
    year={2023},
}
```
- EOL: Encyclopedia of Life. Available from http://eol.org. Accessed 29 July 2023.
For license and citation information by image, see our [license file](https://huggingface.co/datasets/imageomics/treeoflife-10m/blob/main/metadata/licenses.csv).


- ITIS: Retrieved July, 20 2023, from the Integrated Taxonomic Information System (ITIS) on-line database, www.itis.gov, CC0
https://doi.org/10.5066/F7KH0KBK


## Dataset Card Author

Elizabeth G. Campolongo

## Dataset Card Contact

Please use the [Community Tab](https://huggingface.co/datasets/imageomics/ToL-EDA/discussions) for questions. More information on the _published_ project is available on our [project website](https://imageomics.github.io/bioclip/) and at the references therein.