upload main script
Browse files- classes.py +0 -0
- descriptions.py +184 -0
- gadme.py +419 -0
classes.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
descriptions.py
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_HAWAIIAN_ISLANDS_DESCRIPTION = """This collection contains 635 soundscape recordings with a total duration of almost
|
2 |
+
51 hours, which have been annotated by expert ornithologists who provided 59,583 bounding box labels for 27 different
|
3 |
+
bird species from the Hawaiian Islands, including 6 threatened or endangered native birds. The data were recorded
|
4 |
+
between 2016 and 2022 at four sites across Hawai‘i Island. This collection has partially been featured as test data
|
5 |
+
in the 2022 BirdCLEF competition and can primarily be used for training and evaluation of machine learning
|
6 |
+
algorithms."""
|
7 |
+
|
8 |
+
_HAWAIIAN_ISLANDS_CITATION = """@dataset{amanda_navine_2022_7078499,
|
9 |
+
author = {Amanda Navine and
|
10 |
+
Stefan Kahl and
|
11 |
+
Ann Tanimoto-Johnson and
|
12 |
+
Holger Klinck and
|
13 |
+
Patrick Hart},
|
14 |
+
title = {{A collection of fully-annotated soundscape
|
15 |
+
recordings from the Island of Hawai'i}},
|
16 |
+
month = sep,
|
17 |
+
year = 2022,
|
18 |
+
publisher = {Zenodo},
|
19 |
+
version = 1,
|
20 |
+
}"""
|
21 |
+
|
22 |
+
_SAPSUCKER_WOODS_DESCRIPTION = """This collection contains 285 hour-long soundscape recordings, which have been
|
23 |
+
annotated by expert ornithologists who provided 50,760 bounding box labels for 81 different bird species from the
|
24 |
+
Northeastern USA. The data were recorded in 2017 in the Sapsucker Woods bird sanctuary in Ithaca, NY,
|
25 |
+
USA. This collection has (partially) been featured as test data in the 2019, 2020 and 2021 BirdCLEF competition and
|
26 |
+
can primarily be used for training and evaluation of machine learning algorithms."""
|
27 |
+
|
28 |
+
_SAPSUCKER_WOODS_CITATION = """@dataset{stefan_kahl_2022_7079380,
|
29 |
+
author = {Stefan Kahl and
|
30 |
+
Russell Charif and
|
31 |
+
Holger Klinck},
|
32 |
+
title = {{A collection of fully-annotated soundscape
|
33 |
+
recordings from the Northeastern United States}},
|
34 |
+
month = sep,
|
35 |
+
year = 2022,
|
36 |
+
publisher = {Zenodo},
|
37 |
+
version = 2,
|
38 |
+
}"""
|
39 |
+
|
40 |
+
_AMAZON_BASIN_DESCRIPTION = """This collection contains 21 hour-long soundscape recordings, which have been annotated
|
41 |
+
with 14,798 bounding box labels for 132 different bird species from the Southwestern Amazon Basin. The data were
|
42 |
+
recorded in 2019 in the Inkaterra Reserva Amazonica, Madre de Dios, Peru. This collection has partially been featured
|
43 |
+
as test data in the 2020 BirdCLEF competition and can primarily be used for training and evaluation of machine
|
44 |
+
learning algorithms."""
|
45 |
+
|
46 |
+
_AMAZON_BASIN_CITATION = """@dataset{w_alexander_hopping_2022_7079124,
|
47 |
+
author = {W. Alexander Hopping and
|
48 |
+
Stefan Kahl and
|
49 |
+
Holger Klinck},
|
50 |
+
title = {{A collection of fully-annotated soundscape
|
51 |
+
recordings from the Southwestern Amazon Basin}},
|
52 |
+
month = sep,
|
53 |
+
year = 2022,
|
54 |
+
publisher = {Zenodo},
|
55 |
+
version = 1,
|
56 |
+
}"""
|
57 |
+
|
58 |
+
_SIERRA_NEVADA_DESCRIPTION = """This collection contains 33 hour-long soundscape recordings, which have been
|
59 |
+
annotated with 20,147 bounding box labels for 56 different bird species from the Western United States. The data were
|
60 |
+
recorded in 2018 in the Sierra Nevada, California, USA. This collection has partially been featured as test data in
|
61 |
+
the 2021 BirdCLEF competition and can primarily be used for training and evaluation of machine learning algorithms."""
|
62 |
+
|
63 |
+
_SIERRA_NEVADA_CITATION = """@dataset{stefan_kahl_2022_7050014,
|
64 |
+
author = {Stefan Kahl and
|
65 |
+
Connor M. Wood and
|
66 |
+
Philip Chaon and
|
67 |
+
M. Zachariah Peery and
|
68 |
+
Holger Klinck},
|
69 |
+
title = {{A collection of fully-annotated soundscape
|
70 |
+
recordings from the Western United States}},
|
71 |
+
month = sep,
|
72 |
+
year = 2022,
|
73 |
+
publisher = {Zenodo},
|
74 |
+
version = 1,
|
75 |
+
}"""
|
76 |
+
|
77 |
+
_POWDERMILL_NATURE_DESCRIPTION = """Acoustic recordings of soundscapes are an important category of audio data which
|
78 |
+
can be useful for answering a variety of questions, and an entire discipline within ecology, dubbed "soundscape
|
79 |
+
ecology," has risen to study them. Bird sound is often the focus of studies of soundscapes due to the ubiquitousness
|
80 |
+
of birds in most terrestrial environments and their high vocal activity. Autonomous acoustic recorders have increased
|
81 |
+
the quantity and availability of recordings of natural soundscapes while mitigating the impact of human observers on
|
82 |
+
community behavior. However, such recordings are of little use without analysis of the sounds they contain. Manual
|
83 |
+
analysis currently stands as the best means of processing this form of data for use in certain applications within
|
84 |
+
soundscape ecology, but it is a laborious task, sometimes requiring many hours of human review to process
|
85 |
+
comparatively few hours of recording. For this reason, few annotated datasets of soundscape recordings are publicly
|
86 |
+
available. Further still, there are no publicly available strongly-labeled soundscape recordings of bird sounds which
|
87 |
+
contain information on timing, frequency, and species. Therefore, we present the first dataset of strongly-labeled
|
88 |
+
bird sound soundscape recordings under free use license. These data were collected in the Northeastern United States
|
89 |
+
at Powdermill Nature Reserve, Rector, PA. Recordings encompass 385 minutes of dawn chorus recordings collected by
|
90 |
+
autonomous acoustic recorders between the months of April through July 2018. Recordings were collected in continuous
|
91 |
+
bouts on four days during the study period, and contain 48 species and 16,052 annotations. Applications of this
|
92 |
+
dataset may be numerous, and include the training, validation, and testing of certain advanced machine learning
|
93 |
+
models which detect or classify bird sounds."""
|
94 |
+
|
95 |
+
_POWDERMILL_NATURE_CITATION = """@dataset{chronister_2021_4656848,
|
96 |
+
author = {Chronister, Lauren M. and
|
97 |
+
Rhinehart, Tessa A. and
|
98 |
+
Place, Aidan and
|
99 |
+
Kitzes, Justin},
|
100 |
+
title = {{An annotated set of audio recordings of Eastern
|
101 |
+
North American birds containing frequency, time,
|
102 |
+
and species information}},
|
103 |
+
month = apr,
|
104 |
+
year = 2021,
|
105 |
+
publisher = {Zenodo},
|
106 |
+
}"""
|
107 |
+
|
108 |
+
_HIGH_SIERRAS_DESCRIPTION = """This collection contains 100 soundscape recordings of 10 minutes duration, which have
|
109 |
+
been annotated with 10,296 bounding box labels for 21 different bird species from the Western United States. The data
|
110 |
+
were recorded in 2015 in the southern end of the Sierra Nevada mountain range in California, USA. This collection has
|
111 |
+
been featured as test data in the 2020 BirdCLEF and Kaggle Birdcall Identification competition and can primarily be
|
112 |
+
used for training and evaluation of machine learning algorithms."""
|
113 |
+
|
114 |
+
_HIGH_SIERRAS_CITATION = """@dataset{mary_clapp_2023_7525805,
|
115 |
+
author = {Mary Clapp and
|
116 |
+
Stefan Kahl and
|
117 |
+
Erik Meyer and
|
118 |
+
Megan McKenna and
|
119 |
+
Holger Klinck and
|
120 |
+
Gail Patricelli},
|
121 |
+
title = {{A collection of fully-annotated soundscape
|
122 |
+
recordings from the southern Sierra Nevada
|
123 |
+
mountain range}},
|
124 |
+
month = jan,
|
125 |
+
year = 2023,
|
126 |
+
publisher = {Zenodo},
|
127 |
+
version = 1,
|
128 |
+
}"""
|
129 |
+
|
130 |
+
_COLUMBIA_COSTA_RICA_DESCRIPTION = """This collection contains 34 hour-long soundscape recordings, which have been
|
131 |
+
annotated by expert ornithologists who provided 6,952 bounding box labels for 89 different bird species from Colombia
|
132 |
+
and Costa Rica. The data were recorded in 2019 at two highly diverse neotropical coffee farm landscapes from the
|
133 |
+
towns of Jardín, Colombia and San Ramon, Costa Rica. This collection has partially been featured as test data in the
|
134 |
+
2021 BirdCLEF competition and can primarily be used for training and evaluation of machine learning algorithms."""
|
135 |
+
|
136 |
+
_COLUMBIA_COSTA_RICA_CITATION = """@dataset{alvaro_vega_hidalgo_2023_7525349,
|
137 |
+
author = {Álvaro Vega-Hidalgo and
|
138 |
+
Stefan Kahl and
|
139 |
+
Laurel B. Symes and
|
140 |
+
Viviana Ruiz-Gutiérrez and
|
141 |
+
Ingrid Molina-Mora and
|
142 |
+
Fernando Cediel and
|
143 |
+
Luis Sandoval and
|
144 |
+
Holger Klinck},
|
145 |
+
title = {{A collection of fully-annotated soundscape
|
146 |
+
recordings from neotropical coffee farms in
|
147 |
+
Colombia and Costa Rica}},
|
148 |
+
month = jan,
|
149 |
+
year = 2023,
|
150 |
+
publisher = {Zenodo},
|
151 |
+
version = 1,
|
152 |
+
}"""
|
153 |
+
|
154 |
+
_NIPS4BPLUS_DESCRIPTION = """The zip file contains 674 individual recording temporal annotations for the training set
|
155 |
+
of the NIPS4B 2013 dataset in the birdsong classifications task (original size of dataset is 687 recordings)."""
|
156 |
+
|
157 |
+
_NIPS4BPLUS_CITATION = """@article{Morfi2019,
|
158 |
+
author = "Veronica Morfi and Dan Stowell and Hanna Pamula",
|
159 |
+
title = "{NIPS4Bplus: Transcriptions of NIPS4B 2013 Bird Challenge Training Dataset}",
|
160 |
+
year = "2019",
|
161 |
+
month = "7",
|
162 |
+
url = "https://figshare.com/articles/dataset/Transcriptions_of_NIPS4B_2013_Bird_Challenge_Training_Dataset/6798548",
|
163 |
+
doi = "10.6084/m9.figshare.6798548.v7"
|
164 |
+
}"""
|
165 |
+
|
166 |
+
_BIRD_DB_DESCRIPTION = """Projects on the acoustic monitoring of animals in natural habitats generally face the
|
167 |
+
problem of managing extensive amounts of data, both needed for – and produced by – observation or experimentation.
|
168 |
+
While there are many publicly accessible databases for recordings themselves, we are aware of none for annotated song
|
169 |
+
sequences. In this paper, we describe our database system of bird vocalizations and introduce our online sample
|
170 |
+
repository for the community of researchers studying the syntax of bird song."""
|
171 |
+
|
172 |
+
_BIRD_DB_CITATION = """@article{ARRIAGA201521,
|
173 |
+
title = {Bird-DB: A database for annotated bird song sequences},
|
174 |
+
journal = {Ecological Informatics},
|
175 |
+
volume = {27},
|
176 |
+
pages = {21-25},
|
177 |
+
year = {2015},
|
178 |
+
issn = {1574-9541},
|
179 |
+
doi = {https://doi.org/10.1016/j.ecoinf.2015.01.007},
|
180 |
+
url = {https://www.sciencedirect.com/science/article/pii/S1574954115000151},
|
181 |
+
author = {Julio G. Arriaga and Martin L. Cody and Edgar E. Vallejo and Charles E. Taylor},
|
182 |
+
keywords = {Bioacoustics, Bird song, Phrase sequence, Birdsong syntax, Database},
|
183 |
+
abstract = {Projects on the acoustic monitoring of animals in natural habitats generally face the problem of managing extensive amounts of data, both needed for – and produced by – observation or experimentation. While there are many publicly accessible databases for recordings themselves, we are aware of none for annotated song sequences. In this paper, we describe our database system of bird vocalizations and introduce our online sample repository for the community of researchers studying the syntax of bird song.}
|
184 |
+
}"""
|
gadme.py
ADDED
@@ -0,0 +1,419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
# TODO: Address all TODOs and remove all explanatory comments
|
15 |
+
"""BirdSet: The General Avian Monitoring Evaluation Benchmark"""
|
16 |
+
|
17 |
+
import os
|
18 |
+
import datasets
|
19 |
+
import pandas as pd
|
20 |
+
|
21 |
+
from .classes import BIRD_NAMES_BIRDDB, BIRD_NAMES_NIPS4BPLUS, BIRD_NAMES_AMAZON_BASIN, BIRD_NAMES_HAWAII, \
|
22 |
+
BIRD_NAMES_HIGH_SIERRAS, BIRD_NAMES_SIERRA_NEVADA, BIRD_NAMES_POWDERMILL_NATURE, BIRD_NAMES_SAPSUCKER, \
|
23 |
+
BIRD_NAMES_COLUMBIA_COSTA_RICA, BIRD_NAMES_XENOCANTO
|
24 |
+
|
25 |
+
from .descriptions import _BIRD_DB_DESCRIPTION, _BIRD_DB_CITATION, _NIPS4BPLUS_CITATION, _NIPS4BPLUS_DESCRIPTION, \
|
26 |
+
_HIGH_SIERRAS_DESCRIPTION, _HIGH_SIERRAS_CITATION, _SIERRA_NEVADA_DESCRIPTION, _SIERRA_NEVADA_CITATION, \
|
27 |
+
_POWDERMILL_NATURE_DESCRIPTION, _POWDERMILL_NATURE_CITATION, _AMAZON_BASIN_DESCRIPTION, _AMAZON_BASIN_CITATION, \
|
28 |
+
_SAPSUCKER_WOODS_DESCRIPTION, _SAPSUCKER_WOODS_CITATION, _COLUMBIA_COSTA_RICA_CITATION, \
|
29 |
+
_COLUMBIA_COSTA_RICA_DESCRIPTION, _HAWAIIAN_ISLANDS_CITATION, _HAWAIIAN_ISLANDS_DESCRIPTION
|
30 |
+
|
31 |
+
#############################################
|
32 |
+
_BIRDSET_CITATION = """\
|
33 |
+
@article{rauch2024,
|
34 |
+
title = {BirdSet: A Multi-Task Benchmark For Avian Diversity Monitoring},
|
35 |
+
author={Rauch, Lukas and Schwinger, Raphael and Wirth, Moritz and Lange, Jonas and Heinrich, René},
|
36 |
+
year={2024}
|
37 |
+
}
|
38 |
+
"""
|
39 |
+
_BIRDSET_DESCRIPTION = """\
|
40 |
+
This dataset offers a unified, well-structured platform for avian bioacoustics and consists of various tasks. \
|
41 |
+
By creating a set of tasks, BirdSet enables an overall performance score for models and uncovers their limitations \
|
42 |
+
in certain areas.
|
43 |
+
Note that each BirdSet dataset has its own citation. Please see the source to get the correct citation for each
|
44 |
+
contained dataset.
|
45 |
+
"""
|
46 |
+
|
47 |
+
base_url = "https://huggingface.co/datasets/DBD-research-group/gadme_v1/resolve/data"
|
48 |
+
|
49 |
+
|
50 |
+
#base_url = "data" # set this to load localy
|
51 |
+
|
52 |
+
|
53 |
+
class BirdSetConfig(datasets.BuilderConfig):
|
54 |
+
def __init__(
|
55 |
+
self,
|
56 |
+
name,
|
57 |
+
citation,
|
58 |
+
class_list,
|
59 |
+
**kwargs):
|
60 |
+
super().__init__(version=datasets.Version("0.0.1"), name=name, **kwargs)
|
61 |
+
|
62 |
+
features = datasets.Features({
|
63 |
+
"audio": datasets.Audio(sampling_rate=32_000, mono=True, decode=True),
|
64 |
+
"filepath": datasets.Value("string"),
|
65 |
+
"start_time": datasets.Value("float64"), # can be changed to timestamp later
|
66 |
+
"end_time": datasets.Value("float64"),
|
67 |
+
"low_freq": datasets.Value("int64"),
|
68 |
+
"high_freq": datasets.Value("int64"),
|
69 |
+
"ebird_code": datasets.ClassLabel(names=class_list),
|
70 |
+
"ebird_code_multiclass": datasets.Sequence(datasets.ClassLabel(names=class_list)),
|
71 |
+
"ebird_code_secondary": datasets.Sequence(datasets.Value("string")),
|
72 |
+
"call_type": datasets.Value("string"),
|
73 |
+
"sex": datasets.Value("string"),
|
74 |
+
"lat": datasets.Value("float64"),
|
75 |
+
"long": datasets.Value("float64"),
|
76 |
+
"length": datasets.Value("int64"),
|
77 |
+
"microphone": datasets.Value("string"),
|
78 |
+
"license": datasets.Value("string"),
|
79 |
+
"source": datasets.Value("string"),
|
80 |
+
"local_time": datasets.Value("string"),
|
81 |
+
"detected_events": datasets.Sequence(datasets.Sequence(datasets.Value("float64"))),
|
82 |
+
"event_cluster": datasets.Sequence(datasets.Value("int64")),
|
83 |
+
"quality": datasets.Value("string"),
|
84 |
+
"recordist": datasets.Value("string"),
|
85 |
+
})
|
86 |
+
|
87 |
+
self.features = features
|
88 |
+
self.citation = citation
|
89 |
+
|
90 |
+
|
91 |
+
class BirdSet(datasets.GeneratorBasedBuilder):
|
92 |
+
"""TODO: Short description of my dataset."""
|
93 |
+
# ram problems?
|
94 |
+
DEFAULT_WRITER_BATCH_SIZE = 500
|
95 |
+
|
96 |
+
BUILDER_CONFIGS = [
|
97 |
+
BirdSetConfig(
|
98 |
+
name="sapsucker_woods",
|
99 |
+
description=_SAPSUCKER_WOODS_DESCRIPTION,
|
100 |
+
citation=_SAPSUCKER_WOODS_CITATION,
|
101 |
+
data_dir=f"{base_url}/SSW",
|
102 |
+
class_list=BIRD_NAMES_SAPSUCKER,
|
103 |
+
),
|
104 |
+
BirdSetConfig(
|
105 |
+
name="sapsucker_woods_xc",
|
106 |
+
description=_SAPSUCKER_WOODS_DESCRIPTION,
|
107 |
+
citation=_SAPSUCKER_WOODS_CITATION,
|
108 |
+
data_dir=f"{base_url}/SSW",
|
109 |
+
class_list=BIRD_NAMES_SAPSUCKER,
|
110 |
+
),
|
111 |
+
BirdSetConfig(
|
112 |
+
name="sapsucker_woods_scape",
|
113 |
+
description=_SAPSUCKER_WOODS_DESCRIPTION,
|
114 |
+
citation=_SAPSUCKER_WOODS_CITATION,
|
115 |
+
data_dir=f"{base_url}/SSW",
|
116 |
+
class_list=BIRD_NAMES_SAPSUCKER,
|
117 |
+
),
|
118 |
+
BirdSetConfig(
|
119 |
+
name="amazon_basin",
|
120 |
+
description=_AMAZON_BASIN_DESCRIPTION,
|
121 |
+
citation=_AMAZON_BASIN_CITATION,
|
122 |
+
data_dir=f"{base_url}/PER",
|
123 |
+
class_list=BIRD_NAMES_AMAZON_BASIN,
|
124 |
+
),
|
125 |
+
BirdSetConfig(
|
126 |
+
name="amazon_basin_xc",
|
127 |
+
description=_AMAZON_BASIN_DESCRIPTION,
|
128 |
+
citation=_AMAZON_BASIN_CITATION,
|
129 |
+
data_dir=f"{base_url}/PER",
|
130 |
+
class_list=BIRD_NAMES_AMAZON_BASIN,
|
131 |
+
),
|
132 |
+
BirdSetConfig(
|
133 |
+
name="amazon_basin_scape",
|
134 |
+
description=_AMAZON_BASIN_DESCRIPTION,
|
135 |
+
citation=_AMAZON_BASIN_CITATION,
|
136 |
+
data_dir=f"{base_url}/PER",
|
137 |
+
class_list=BIRD_NAMES_AMAZON_BASIN,
|
138 |
+
),
|
139 |
+
BirdSetConfig( # TODO _xc and _scape
|
140 |
+
name="hawaiian_islands",
|
141 |
+
description=_HAWAIIAN_ISLANDS_DESCRIPTION,
|
142 |
+
citation=_HAWAIIAN_ISLANDS_CITATION,
|
143 |
+
data_dir=f"{base_url}/UHH",
|
144 |
+
class_list=BIRD_NAMES_HAWAII,
|
145 |
+
),
|
146 |
+
BirdSetConfig(
|
147 |
+
name="sierra_nevada",
|
148 |
+
description=_SIERRA_NEVADA_DESCRIPTION,
|
149 |
+
citation=_SIERRA_NEVADA_CITATION,
|
150 |
+
data_dir=f"{base_url}/SNE",
|
151 |
+
class_list=BIRD_NAMES_SIERRA_NEVADA,
|
152 |
+
),
|
153 |
+
BirdSetConfig(
|
154 |
+
name="sierra_nevada_xc",
|
155 |
+
description=_SIERRA_NEVADA_DESCRIPTION,
|
156 |
+
citation=_SIERRA_NEVADA_CITATION,
|
157 |
+
data_dir=f"{base_url}/SNE",
|
158 |
+
class_list=BIRD_NAMES_SIERRA_NEVADA,
|
159 |
+
),
|
160 |
+
BirdSetConfig(
|
161 |
+
name="sierra_nevada_scape",
|
162 |
+
description=_SIERRA_NEVADA_DESCRIPTION,
|
163 |
+
citation=_SIERRA_NEVADA_CITATION,
|
164 |
+
data_dir=f"{base_url}/SNE",
|
165 |
+
class_list=BIRD_NAMES_SIERRA_NEVADA,
|
166 |
+
),
|
167 |
+
BirdSetConfig(
|
168 |
+
name="powdermill_nature",
|
169 |
+
description=_POWDERMILL_NATURE_DESCRIPTION,
|
170 |
+
citation=_POWDERMILL_NATURE_CITATION,
|
171 |
+
data_dir=f"{base_url}/POW",
|
172 |
+
class_list=BIRD_NAMES_POWDERMILL_NATURE,
|
173 |
+
),
|
174 |
+
BirdSetConfig(
|
175 |
+
name="powdermill_nature_xc",
|
176 |
+
description=_POWDERMILL_NATURE_DESCRIPTION,
|
177 |
+
citation=_POWDERMILL_NATURE_CITATION,
|
178 |
+
data_dir=f"{base_url}/POW",
|
179 |
+
class_list=BIRD_NAMES_POWDERMILL_NATURE,
|
180 |
+
),
|
181 |
+
BirdSetConfig(
|
182 |
+
name="powdermill_nature_scape",
|
183 |
+
description=_POWDERMILL_NATURE_DESCRIPTION,
|
184 |
+
citation=_POWDERMILL_NATURE_CITATION,
|
185 |
+
data_dir=f"{base_url}/POW",
|
186 |
+
class_list=BIRD_NAMES_POWDERMILL_NATURE,
|
187 |
+
),
|
188 |
+
BirdSetConfig(
|
189 |
+
name="high_sierras",
|
190 |
+
description=_HIGH_SIERRAS_DESCRIPTION,
|
191 |
+
citation=_HIGH_SIERRAS_CITATION,
|
192 |
+
data_dir=f"{base_url}/HSN",
|
193 |
+
class_list=BIRD_NAMES_HIGH_SIERRAS,
|
194 |
+
),
|
195 |
+
BirdSetConfig(
|
196 |
+
name="high_sierras_xc",
|
197 |
+
description=_HIGH_SIERRAS_DESCRIPTION,
|
198 |
+
citation=_HIGH_SIERRAS_CITATION,
|
199 |
+
data_dir=f"{base_url}/HSN",
|
200 |
+
class_list=BIRD_NAMES_HIGH_SIERRAS,
|
201 |
+
),
|
202 |
+
BirdSetConfig(
|
203 |
+
name="high_sierras_scape",
|
204 |
+
description=_HIGH_SIERRAS_DESCRIPTION,
|
205 |
+
citation=_HIGH_SIERRAS_CITATION,
|
206 |
+
data_dir=f"{base_url}/HSN",
|
207 |
+
class_list=BIRD_NAMES_HIGH_SIERRAS,
|
208 |
+
),
|
209 |
+
BirdSetConfig(
|
210 |
+
name="columbia_costa_rica",
|
211 |
+
description=_COLUMBIA_COSTA_RICA_DESCRIPTION,
|
212 |
+
citation=_COLUMBIA_COSTA_RICA_CITATION,
|
213 |
+
data_dir=f"{base_url}/NES",
|
214 |
+
class_list=BIRD_NAMES_COLUMBIA_COSTA_RICA,
|
215 |
+
),
|
216 |
+
BirdSetConfig(
|
217 |
+
name="columbia_costa_rica_xc",
|
218 |
+
description=_COLUMBIA_COSTA_RICA_DESCRIPTION,
|
219 |
+
citation=_COLUMBIA_COSTA_RICA_CITATION,
|
220 |
+
data_dir=f"{base_url}/NES",
|
221 |
+
class_list=BIRD_NAMES_COLUMBIA_COSTA_RICA,
|
222 |
+
),
|
223 |
+
BirdSetConfig(
|
224 |
+
name="columbia_costa_rica_scape",
|
225 |
+
description=_COLUMBIA_COSTA_RICA_DESCRIPTION,
|
226 |
+
citation=_COLUMBIA_COSTA_RICA_CITATION,
|
227 |
+
data_dir=f"{base_url}/NES",
|
228 |
+
class_list=BIRD_NAMES_COLUMBIA_COSTA_RICA,
|
229 |
+
),
|
230 |
+
BirdSetConfig(
|
231 |
+
name="nips",
|
232 |
+
description=_NIPS4BPLUS_DESCRIPTION,
|
233 |
+
citation=_NIPS4BPLUS_CITATION,
|
234 |
+
data_dir=f"{base_url}/NIPS",
|
235 |
+
class_list=BIRD_NAMES_NIPS4BPLUS,
|
236 |
+
),
|
237 |
+
BirdSetConfig(
|
238 |
+
name="nips_xc",
|
239 |
+
description=_NIPS4BPLUS_DESCRIPTION,
|
240 |
+
citation=_NIPS4BPLUS_CITATION,
|
241 |
+
data_dir=f"{base_url}/NIPS",
|
242 |
+
class_list=BIRD_NAMES_NIPS4BPLUS,
|
243 |
+
),
|
244 |
+
BirdSetConfig(
|
245 |
+
name="nips_scape",
|
246 |
+
description=_NIPS4BPLUS_DESCRIPTION,
|
247 |
+
citation=_NIPS4BPLUS_CITATION,
|
248 |
+
data_dir=f"{base_url}/NIPS",
|
249 |
+
class_list=BIRD_NAMES_NIPS4BPLUS,
|
250 |
+
),
|
251 |
+
BirdSetConfig(
|
252 |
+
name="xenocanto",
|
253 |
+
description="TODO",
|
254 |
+
citation="TODO",
|
255 |
+
data_dir=f"{base_url}/xenocanto",
|
256 |
+
class_list=BIRD_NAMES_XENOCANTO,
|
257 |
+
),
|
258 |
+
]
|
259 |
+
|
260 |
+
def _info(self):
|
261 |
+
return datasets.DatasetInfo(
|
262 |
+
description=_BIRDSET_DESCRIPTION + self.config.description,
|
263 |
+
features=self.config.features,
|
264 |
+
citation=self.config.citation + "\n" + _BIRDSET_CITATION,
|
265 |
+
)
|
266 |
+
|
267 |
+
def _split_generators(self, dl_manager):
|
268 |
+
ds_name = self.config.name
|
269 |
+
train_files = {"PER": 10,
|
270 |
+
"NES": 12,
|
271 |
+
"UHH": 4,
|
272 |
+
"HSN": 6,
|
273 |
+
"NIPS": 14,
|
274 |
+
"POW": 36,
|
275 |
+
"SSW": 27,
|
276 |
+
"SNE": 20}
|
277 |
+
|
278 |
+
test_files = {"PER": 3,
|
279 |
+
"NES": 8,
|
280 |
+
"UHH": 7,
|
281 |
+
"HSN": 3,
|
282 |
+
"NIPS": 1,
|
283 |
+
"POW": 3,
|
284 |
+
"SSW": 36,
|
285 |
+
"SNE": 5}
|
286 |
+
|
287 |
+
if self.config.name.endswith("_xc"):
|
288 |
+
ds_name = ds_name[:-3]
|
289 |
+
dl_dir = dl_manager.download({
|
290 |
+
"train": [os.path.join(self.config.data_dir, f"{ds_name}_train_shard_{n:04d}.tar.gz") for n in range(1, train_files[ds_name] + 1)],
|
291 |
+
"metadata": os.path.join(self.config.data_dir, f"{ds_name}_metadata_train.parquet"),
|
292 |
+
})
|
293 |
+
|
294 |
+
elif self.config.name.endswith("_scape"):
|
295 |
+
ds_name = ds_name[:-6]
|
296 |
+
dl_dir = dl_manager.download({
|
297 |
+
"test": [os.path.join(self.config.data_dir, f"{ds_name}_test_shard_{n:04d}.tar.gz") for n in range(1, test_files[ds_name] + 1)],
|
298 |
+
"metadata": os.path.join(self.config.data_dir, f"{ds_name}_metadata_test.parquet"),
|
299 |
+
"metadata_5s": os.path.join(self.config.data_dir, f"{ds_name}_metadata_test_5s.parquet"),
|
300 |
+
})
|
301 |
+
|
302 |
+
elif self.config.name == "xenocanto":
|
303 |
+
dl_dir = dl_manager.download({
|
304 |
+
"train": [os.path.join(self.config.data_dir, f"{ds_name}_shard_{n:04d}.tar.gz") for n in range(1, train_files[ds_name] + 1)],
|
305 |
+
"metadata": os.path.join(self.config.data_dir, f"{ds_name}_metadata_metadata.parquet"),
|
306 |
+
})
|
307 |
+
|
308 |
+
elif self.config.name in train_files.keys():
|
309 |
+
dl_dir = dl_manager.download({
|
310 |
+
"train": [os.path.join(self.config.data_dir, f"{ds_name}_train_shard_{n:04d}.tar.gz") for n in range(1, train_files[ds_name] + 1)],
|
311 |
+
"test": [os.path.join(self.config.data_dir, f"{ds_name}_test_shard_{n:04d}.tar.gz") for n in range(1, test_files[ds_name] + 1)],
|
312 |
+
"meta_train": os.path.join(self.config.data_dir, f"{ds_name}_metadata_train.parquet"),
|
313 |
+
"meta_test": os.path.join(self.config.data_dir, f"{ds_name}_metadata_test.parquet"),
|
314 |
+
"meta_test_5s": os.path.join(self.config.data_dir, f"{ds_name}_metadata_test_5s.parquet"),
|
315 |
+
})
|
316 |
+
|
317 |
+
local_audio_archives_paths = dl_manager.extract(dl_dir) if not dl_manager.is_streaming else None
|
318 |
+
|
319 |
+
if self.config.name == "xenocanto" or self.config.name.endswith("_xc"):
|
320 |
+
return [
|
321 |
+
datasets.SplitGenerator(
|
322 |
+
name=datasets.Split.TRAIN,
|
323 |
+
gen_kwargs={
|
324 |
+
"audio_archive_iterators": [dl_manager.iter_archive(archive_path) for archive_path in dl_dir["train"]],
|
325 |
+
"local_audio_archives_paths": local_audio_archives_paths["train"] if local_audio_archives_paths else None,
|
326 |
+
"metapath": dl_dir["metadata"],
|
327 |
+
"split": datasets.Split.TRAIN,
|
328 |
+
},
|
329 |
+
),
|
330 |
+
]
|
331 |
+
|
332 |
+
elif self.config.name.endswith("_scape"):
|
333 |
+
return [
|
334 |
+
datasets.SplitGenerator(
|
335 |
+
name=datasets.Split.TEST,
|
336 |
+
gen_kwargs={
|
337 |
+
"audio_archive_iterators": [dl_manager.iter_archive(archive_path) for archive_path in dl_dir["test"]],
|
338 |
+
"local_audio_archives_paths": local_audio_archives_paths["test"] if local_audio_archives_paths else None,
|
339 |
+
"metapath": dl_dir["metadata"],
|
340 |
+
"split": datasets.Split.TEST,
|
341 |
+
},
|
342 |
+
),
|
343 |
+
datasets.SplitGenerator(
|
344 |
+
name="test_5s",
|
345 |
+
gen_kwargs={
|
346 |
+
"audio_archive_iterators": [dl_manager.iter_archive(archive_path) for archive_path in dl_dir["test"]],
|
347 |
+
"local_audio_archives_paths": local_audio_archives_paths["test"] if local_audio_archives_paths else None,
|
348 |
+
"metapath": dl_dir["metadata_5s"],
|
349 |
+
"split": "test_multiclass"
|
350 |
+
},
|
351 |
+
),
|
352 |
+
]
|
353 |
+
|
354 |
+
return [
|
355 |
+
datasets.SplitGenerator(
|
356 |
+
name=datasets.Split.TRAIN,
|
357 |
+
gen_kwargs={
|
358 |
+
"audio_archive_iterators": [dl_manager.iter_archive(archive_path) for archive_path in dl_dir["train"]],
|
359 |
+
"local_audio_archives_paths": local_audio_archives_paths["train"] if local_audio_archives_paths else None,
|
360 |
+
"metapath": dl_dir["meta_train"],
|
361 |
+
"split": datasets.Split.TRAIN,
|
362 |
+
},
|
363 |
+
),
|
364 |
+
datasets.SplitGenerator(
|
365 |
+
name=datasets.Split.TEST,
|
366 |
+
gen_kwargs={
|
367 |
+
"audio_archive_iterators": [dl_manager.iter_archive(archive_path) for archive_path in dl_dir["test"]],
|
368 |
+
"local_audio_archives_paths": local_audio_archives_paths["test"] if local_audio_archives_paths else None,
|
369 |
+
"metapath": dl_dir["meta_test"],
|
370 |
+
"split": datasets.Split.TEST,
|
371 |
+
},
|
372 |
+
),
|
373 |
+
datasets.SplitGenerator(
|
374 |
+
name="test_5s",
|
375 |
+
gen_kwargs={
|
376 |
+
"audio_archive_iterators": [dl_manager.iter_archive(archive_path) for archive_path in dl_dir["test"]],
|
377 |
+
"local_audio_archives_paths": local_audio_archives_paths["test"] if local_audio_archives_paths else None,
|
378 |
+
"metapath": dl_dir["meta_test_5s"],
|
379 |
+
"split": "test_multiclass"
|
380 |
+
},
|
381 |
+
),
|
382 |
+
]
|
383 |
+
|
384 |
+
def _generate_examples(self, audio_archive_iterators, local_audio_archives_paths, metapath, split):
|
385 |
+
metadata = pd.read_parquet(metapath)
|
386 |
+
idx = 0
|
387 |
+
for i, audio_archive_iterator in enumerate(audio_archive_iterators):
|
388 |
+
for audio_path_in_archive, audio_file in audio_archive_iterator:
|
389 |
+
id = os.path.split(audio_path_in_archive)[-1]
|
390 |
+
rows = metadata.loc[[int(id[2:].split(".")[0])] if split == "train" else [id]]
|
391 |
+
audio_path = os.path.join(local_audio_archives_paths[i], audio_path_in_archive) if local_audio_archives_paths else audio_path_in_archive
|
392 |
+
|
393 |
+
audio = audio_path if local_audio_archives_paths else audio_file.read()
|
394 |
+
for _, row in rows.iterrows():
|
395 |
+
idx += 1
|
396 |
+
yield id if split == "train" else idx, {
|
397 |
+
"audio": audio,
|
398 |
+
"filepath": audio_path,
|
399 |
+
"start_time": row["start_time"],
|
400 |
+
"end_time": row["end_time"],
|
401 |
+
"low_freq": row["low_freq"],
|
402 |
+
"high_freq": row["high_freq"],
|
403 |
+
"ebird_code": row["ebird_code"] if split != "test_multiclass" else None,
|
404 |
+
"ebird_code_multiclass": None if split != "test_multiclass" else row.get("ebird_code_multiclass", None),
|
405 |
+
"ebird_code_secondary": row.get("ebird_code_multiclass", None),
|
406 |
+
"call_type": row["call_type"],
|
407 |
+
"sex": row["sex"],
|
408 |
+
"lat": row["lat"],
|
409 |
+
"long": row["long"],
|
410 |
+
"length": row.get("length", None),
|
411 |
+
"microphone": row["microphone"],
|
412 |
+
"license": row.get("license", None),
|
413 |
+
"source": row["source"],
|
414 |
+
"local_time": row["local_time"],
|
415 |
+
"detected_events": row.get("detected_events", None),
|
416 |
+
"event_cluster": row.get("event_cluster", None),
|
417 |
+
"quality": row.get("quality", None),
|
418 |
+
"recordist": row.get("recordist", None)
|
419 |
+
}
|