File size: 7,941 Bytes
0a0b2ac
4e4be4d
 
c12bb45
4e4be4d
c12bb45
92fbaac
 
c12bb45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e97977
c12bb45
 
4e97977
 
c12bb45
4e97977
 
 
 
 
0435223
c12bb45
c7713b9
0435223
 
648d7fd
0435223
401d235
f49869f
0435223
 
401d235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0435223
d857c74
0435223
c7713b9
 
0435223
a6882d9
 
086a9df
0435223
086a9df
0435223
 
 
 
 
086a9df
 
 
0435223
086a9df
 
0435223
 
413f4a2
5e43eea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c38b36f
 
 
 
 
 
 
c7713b9
5e43eea
 
 
c6299bb
5e43eea
 
4a3fef6
ad878d3
a274f8b
cfa4a7d
85a4161
ffc5e34
 
 
 
 
 
a274f8b
ffc5e34
5e43eea
 
764479c
 
904ac9d
 
 
 
 
 
 
764479c
 
 
904ac9d
764479c
 
 
 
 
 
 
982a1ab
 
764479c
5e43eea
c7713b9
 
 
6831418
c7713b9
 
 
 
 
 
 
 
 
 
 
 
413f4a2
 
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
---
license: cc-by-3.0
language:
  - en
size_categories:
  - 1M<n<10M
pretty_name: BIOSCAN-5M
tags:
  - Multimodal_dataset
  - Large_dcale_dataset
  - Image
  - DNA_barcode
  - Taxonomy
  - Biodiversity
  - LLMs
  - BERT
  - Clustering
  - Multimodal_retrieval_learning
  - Zero_shot_transfer_learning
  - Geo_location
  - Specimen_size
  - Insect
  - Species
maintainers:
  - https://huggingface.co/Gharaee
author:
  name: Zahra Gharaee
  github: https://github.com/zahrag
  hf: https://huggingface.co/Gharaee
dataset_loader_script: dataset.py
dataset_split_names:
  - pretarin
  - train
  - validation
  - test
  - val_unseen
  - test_unseen
  - key_unseen
  - other_heldout
---
[![Author: zahrag](https://img.shields.io/badge/author-zahrag-blue)](https://huggingface.co/Gharaee)

# Dataset Card for BIOSCAN-5M

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64cac7e17221ef3c7e2eed1f/ZgP3fd2Z9eVgucsZHYYvA.png)

## Overview
As part of an ongoing worldwide effort to comprehend and monitor insect biodiversity, we present the BIOSCAN-5M Insect dataset to the machine learning community. BIOSCAN-5M is a comprehensive dataset containing multi-modal information for over 5 million insect specimens, 
and it significantly expands existing image-based biological datasets by including taxonomic labels, raw nucleotide barcode sequences, assigned barcode index numbers, geographical information, and specimen size. 

### Large-Scale Foundation Model Training

#### BIOSCAN-5M is partitioned to support both closed-world and open-world biodiversity learning:

- **Closed-world (train, val, test):**
Samples with known species names for supervised classification.

- **Open-world (key_unseen, val_unseen, test_unseen):**
Placeholder species but known genera, enabling generalization to unseen species.

- **Novelty detection (other_heldout):**
Unknown species and genus, suitable for open-set detection.

- **Pretraining (pretrain):**
Unlabeled data for self- or semi-supervised learning at scale.

#### Supported Tasks
- **Task I: DNA-based Taxonomic Classification**
Predict taxonomic labels from raw DNA barcode sequences.

- **Task II: Zero-Shot Transfer Learning**
Evaluate whether unlabeled models can organize data into semantically meaningful clusters—across modalities like image and DNA—using learned representations.

- **Task III: Multimodal Retrieval Learning**
Retrieve matching specimens across modalities (e.g., image ↔ DNA ↔ Text) using shared embeddings.

### Citation

If you make use of the BIOSCAN-5M dataset and/or its code repository, please cite the following paper:

```
cite as:

@inproceedings{gharaee2024bioscan5m,
    title={{BIOSCAN-5M}: A Multimodal Dataset for Insect Biodiversity},
    booktitle={Advances in Neural Information Processing Systems},
    author={Zahra Gharaee and Scott C. Lowe and ZeMing Gong and Pablo Millan Arias
        and Nicholas Pellegrino and Austin T. Wang and Joakim Bruslund Haurum
        and Iuliia Zarubiieva and Lila Kari and Dirk Steinke and Graham W. Taylor
        and Paul Fieguth and Angel X. Chang
    },
    editor={A. Globerson and L. Mackey and D. Belgrave and A. Fan and U. Paquet and J. Tomczak and C. Zhang},
    pages={36285--36313},
    publisher={Curran Associates, Inc.},
    year={2024},
    volume={37},
    url={https://proceedings.neurips.cc/paper_files/paper/2024/file/3fdbb472813041c9ecef04c20c2b1e5a-Paper-Datasets_and_Benchmarks_Track.pdf},
}
```

## Dataset Features

Each configuration loads specimen images along with associated metadata fields:

- **`image`**  
  RGB JPEG images of individual insect specimens.

- **Metadata fields**
  - **Indexing fields**  
    - `processid`: A unique number assigned by BOLD (International Barcode of Life Consortium).  
    - `sampleid`: A unique identifier given by the collector.  
  - **Taxonomic labels**  
    - `phylum`, `class`, `order`, `family`, `subfamily`, `genus`, `species`: Hierarchical taxonomic classification  
  - **Genetic information**  
    - `dna_bin`: Barcode Index Number  
    - `dna_barcode`: DNA barcode sequence   
  - **Geographic data**  
    - `country`, `province_state`: Collection location  
    - `coord-lat`, `coord-lon`: Latitude and longitude coordinates  
  - **Specimen size data**  
    - `image_measurement_value`: Measured image property (e.g., pixel area)  
    - `area_fraction`: Fraction of the image occupied by the specimen  
    - `scale_factor`: Relative size normalization factor  
  - **Split and localization**  
    - `split`: Data partition label (e.g., train, test, val)  
    - `chunk`: Subdirectory label for scalable storage

## Usage

First, download the `dataset.py` script to your project directory by running the following command:

```python
wget -P /path/to/your/project_directory https://huggingface.co/datasets/bioscan-ml/BIOSCAN-5M/resolve/main/dataset.py
```

Once you've downloaded the script, you can use the `datasets` library to load the dataset. For example:

```python
from datasets import load_dataset

ds = load_dataset("dataset.py", name="cropped_256_eval", split="validation", trust_remote_code=True)
```

> **ℹ️ Note:** The CSV metadata and image package associated with the selected configuration will be automatically downloaded and extracted to `~/.cache/huggingface/datasets/downloads/extracted/` .


### 📑 Configurations

| **`name`**                                      | **Available `split` values**                                                                          |
|---------------------------------------------    |-------------------------------------------------------------------                                    |
| `cropped_256`, `original_256`                   | `pretrain`, `train`, `validation`, `test`, `val_unseen`, `test_unseen`, `key_unseen`, `other_heldout` |
| `cropped_256_pretrain`, `original_256_pretrain` | `pretrain`                                                                                            |
| `cropped_256_train`, `original_256_train`       | `train`                                                                                               |
| `cropped_256_eval`, `original_256_eval`         | `validation`, `test`, `val_unseen`, `test_unseen`, `key_unseen`, `other_heldout`                      |

> **ℹ️ Note:** If you do not specify the `split` when loading the dataset, all available splits will be loaded as a dictionary.


## Sample Usage

First, download the `usage_demo_bioscan5m.py` script to your project directory by running the following command:

```python
wget -P /path/to/your/project_directory https://huggingface.co/datasets/bioscan-ml/BIOSCAN-5M/resolve/main/usage_demo_bioscan5m.py
```

This script demonstrates how to load and visualize samples from the BIOSCAN-5M dataset.

To run the script, execute:


```bash
python usage_demo_bioscan5m.py
```

This will display 10 dataset samples, each showing the organism image on the right, and the corresponding metadata fields on the left, including taxonomic, geographic, genetic, and size-related information.


<img src="https://cdn-uploads.huggingface.co/production/uploads/64cac7e17221ef3c7e2eed1f/qlC1wtjfa_CqOzD2r07Kr.png" alt="image" width="1000"/>


## Dataset Access
To clone this dataset repository, use the following command:

```bash
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/datasets/bioscan-ml/BIOSCAN-5M
```

### Dataset Sources

- **Dataset website:** https://biodiversitygenomics.net/5M-insects/
- **GoogleDrive:** https://drive.google.com/drive/u/1/folders/1Jc57eKkeiYrnUBc9WlIp-ZS_L1bVlT-0
- **GitHub:** https://github.com/zahrag/BIOSCAN-5M
- **Zenodo:** https://zenodo.org/records/11973457
- **Kaggle:** https://www.kaggle.com/datasets/zahragharaee/bioscan-5m/data
- **Paper:** https://arxiv.org/abs/2406.12723



![image/png](https://cdn-uploads.huggingface.co/production/uploads/64cac7e17221ef3c7e2eed1f/DRj7GKEvV4ANbUvGSQvKA.png)