errrrrrmmiii Dragunflie-420 commited on
Commit
6079091
·
verified ·
0 Parent(s):

Duplicate from Dragunflie-420/FMADataset

Browse files

Co-authored-by: Nikki Russell <Dragunflie-420@users.noreply.huggingface.co>

Files changed (3) hide show
  1. .gitattributes +58 -0
  2. README.md +177 -0
  3. fma.py +227 -0
.gitattributes ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
+ *.model filter=lfs diff=lfs merge=lfs -text
14
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
15
+ *.npy filter=lfs diff=lfs merge=lfs -text
16
+ *.npz filter=lfs diff=lfs merge=lfs -text
17
+ *.onnx filter=lfs diff=lfs merge=lfs -text
18
+ *.ot filter=lfs diff=lfs merge=lfs -text
19
+ *.parquet filter=lfs diff=lfs merge=lfs -text
20
+ *.pb filter=lfs diff=lfs merge=lfs -text
21
+ *.pickle filter=lfs diff=lfs merge=lfs -text
22
+ *.pkl filter=lfs diff=lfs merge=lfs -text
23
+ *.pt filter=lfs diff=lfs merge=lfs -text
24
+ *.pth filter=lfs diff=lfs merge=lfs -text
25
+ *.rar filter=lfs diff=lfs merge=lfs -text
26
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
27
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar filter=lfs diff=lfs merge=lfs -text
30
+ *.tflite filter=lfs diff=lfs merge=lfs -text
31
+ *.tgz filter=lfs diff=lfs merge=lfs -text
32
+ *.wasm filter=lfs diff=lfs merge=lfs -text
33
+ *.xz filter=lfs diff=lfs merge=lfs -text
34
+ *.zip filter=lfs diff=lfs merge=lfs -text
35
+ *.zst filter=lfs diff=lfs merge=lfs -text
36
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
37
+ # Audio files - uncompressed
38
+ *.pcm filter=lfs diff=lfs merge=lfs -text
39
+ *.sam filter=lfs diff=lfs merge=lfs -text
40
+ *.raw filter=lfs diff=lfs merge=lfs -text
41
+ # Audio files - compressed
42
+ *.aac filter=lfs diff=lfs merge=lfs -text
43
+ *.flac filter=lfs diff=lfs merge=lfs -text
44
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
45
+ *.ogg filter=lfs diff=lfs merge=lfs -text
46
+ *.wav filter=lfs diff=lfs merge=lfs -text
47
+ # Image files - uncompressed
48
+ *.bmp filter=lfs diff=lfs merge=lfs -text
49
+ *.gif filter=lfs diff=lfs merge=lfs -text
50
+ *.png filter=lfs diff=lfs merge=lfs -text
51
+ *.tiff filter=lfs diff=lfs merge=lfs -text
52
+ # Image files - compressed
53
+ *.jpg filter=lfs diff=lfs merge=lfs -text
54
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
55
+ *.webp filter=lfs diff=lfs merge=lfs -text
56
+ # Video files - compressed
57
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
58
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: cc-by-4.0
5
+ pretty_name: Free Music Archive (FMA) Dataset
6
+ size_categories:
7
+ - 1K<n<10K
8
+ source_datasets:
9
+ - original
10
+ task_categories:
11
+ - audio-classification
12
+ task_ids:
13
+ - multi-class-classification
14
+ ---
15
+
16
+ # Free Music Archive (FMA) Dataset
17
+
18
+ ## Overview
19
+
20
+ This repository contains the Free Music Archive (FMA) dataset, curated and made available on Hugging Face by [dragunflie-420](https://huggingface.co/dragunflie-420). The FMA dataset is a large-scale, open-source dataset of music tracks, designed for music information retrieval and machine learning tasks.
21
+
22
+ ## Dataset Description
23
+
24
+ The Free Music Archive (FMA) is an open and easily accessible dataset consisting of full-length audio tracks with associated metadata. This particular version focuses on the "small" subset of the FMA, which includes:
25
+
26
+ - 8,000 tracks of 30 seconds each
27
+ - 8 balanced genres (Electronic, Experimental, Folk, Hip-Hop, Instrumental, International, Pop, Rock)
28
+ - Audio files in 128k MP3 format
29
+ - Comprehensive metadata for each track
30
+
31
+ ## Contents
32
+
33
+ This dataset provides:
34
+
35
+ 1. Audio files: 30-second MP3 clips of music tracks
36
+ 2. Metadata: Information about each track, including:
37
+ - Track ID
38
+ - Title
39
+ - Artist
40
+ - Genre
41
+ - Additional features (e.g., acoustic features, music analysis data)
42
+
43
+ ## Data Files
44
+
45
+ To use this dataset, you need to manually download and place the following files in the repository:
46
+
47
+ 1. `fma_small.zip`: Contains the audio files
48
+ 2. `fma_metadata.zip`: Contains the metadata for the tracks
49
+
50
+ After downloading, extract these files and ensure the following directory structure:
51
+
52
+ ```
53
+ fma_dataset/
54
+ ├── fma_small/
55
+ │ ├── 000/
56
+ │ ├── 001/
57
+ │ └── ...
58
+ └── fma_metadata/
59
+ ├── tracks.csv
60
+ ├── genres.csv
61
+ └── features.csv
62
+ ```
63
+
64
+ ## Usage
65
+
66
+ To use this dataset in your Hugging Face projects:
67
+
68
+ ```python
69
+ from datasets import load_dataset
70
+
71
+ dataset = load_dataset("dragunflie-420/fma")
72
+
73
+ # Access the first example
74
+ first_example = dataset['train'][0]
75
+ print(first_example['title'], first_example['artist'], first_example['genre'])
76
+
77
+ # Play the audio (if in a notebook environment)
78
+ from IPython.display import Audio
79
+ Audio(first_example['audio']['array'], rate=first_example['audio']['sampling_rate'])
80
+ ```
81
+
82
+ [... rest of the README content remains the same ...]
83
+
84
+
85
+
86
+
87
+
88
+ ---
89
+ language:
90
+ - en
91
+ license: cc-by-4.0
92
+ pretty_name: Free Music Archive (FMA) Dataset
93
+ size_categories:
94
+ - 1K<n<10K
95
+ source_datasets:
96
+ - original
97
+ task_categories:
98
+ - audio-classification
99
+ task_ids:
100
+ - multi-class-classification
101
+ ---
102
+
103
+ # Free Music Archive (FMA) Dataset
104
+
105
+ ## Overview
106
+
107
+ This repository contains the Free Music Archive (FMA) dataset, curated and made available on Hugging Face by [dragunflie-420](https://huggingface.co/dragunflie-420). The FMA dataset is a large-scale, open-source dataset of music tracks, designed for music information retrieval and machine learning tasks.
108
+
109
+ [... rest of the README content remains the same ...] Free Music Archive (FMA) Dataset
110
+
111
+ ## Dataset Description
112
+
113
+ The Free Music Archive (FMA) is an open and easily accessible dataset consisting of full-length audio tracks with associated metadata. This particular version focuses on the "small" subset of the FMA, which includes:
114
+
115
+ - 8,000 tracks of 30 seconds each
116
+ - 8 balanced genres (Electronic, Experimental, Folk, Hip-Hop, Instrumental, International, Pop, Rock)
117
+ - Audio files in 128k MP3 format
118
+ - Comprehensive metadata for each track
119
+
120
+ ## Contents
121
+
122
+ This dataset provides:
123
+
124
+ 1. Audio files: 30-second MP3 clips of music tracks
125
+ 2. Metadata: Information about each track, including:
126
+ - Track ID
127
+ - Title
128
+ - Artist
129
+ - Genre
130
+ - Additional features (e.g., acoustic features, music analysis data)
131
+
132
+ ## Usage
133
+
134
+ To use this dataset in your Hugging Face projects:
135
+
136
+ ```python
137
+ from datasets import load_dataset
138
+
139
+ dataset = load_dataset("dragunflie-420/fma")
140
+
141
+ # Access the first example
142
+ first_example = dataset['train'][0]
143
+ print(first_example['title'], first_example['artist'], first_example['genre'])
144
+
145
+ # Play the audio (if in a notebook environment)
146
+ from IPython.display import Audio
147
+ Audio(first_example['audio']['array'], rate=first_example['audio']['sampling_rate'])
148
+ ```
149
+
150
+ ## Dataset Structure
151
+
152
+ Each example in the dataset contains:
153
+
154
+ - `track_id`: Unique identifier for the track
155
+ - `title`: Title of the track
156
+ - `artist`: Name of the artist
157
+ - `genre`: Top-level genre classification
158
+ - `audio`: Audio file in the format compatible with Hugging Face's Audio feature
159
+
160
+ ## Applications
161
+
162
+ This dataset is suitable for various music information retrieval and machine learning tasks, including:
163
+
164
+ - Music genre classification
165
+ - Artist identification
166
+ - Music recommendation systems
167
+ - Audio feature extraction and analysis
168
+ - Music generation and style transfer
169
+
170
+ ## Citation
171
+
172
+ If you use this dataset in your research, please cite the original FMA paper:
173
+
174
+ ```
175
+ @inproceedings{defferrard2016fma,
176
+ title={FMA: A Dataset for Music Analysis},
177
+ author={Defferrard, Micha{\"e}l and Ben
fma.py ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ import os
17
+ import pandas as pd
18
+ import numpy as np
19
+
20
+ import datasets
21
+
22
+ _CITATION = """
23
+ @inproceedings{defferrard2016fma,
24
+ title={FMA: A Dataset for Music Analysis},
25
+ author={Defferrard, Micha{\"e}l and Benzi, Kirell and Vandergheynst, Pierre and Bresson, Xavier},
26
+ booktitle={18th International Society for Music Information Retrieval Conference},
27
+ year={2017},
28
+ }
29
+ """
30
+
31
+ _DESCRIPTION = """
32
+ The Free Music Archive (FMA) is an open and easily accessible dataset of music collections.
33
+ """
34
+
35
+ _HOMEPAGE = "https://github.com/mdeff/fma"
36
+
37
+ _LICENSE = "Creative Commons Attribution 4.0 International License"
38
+
39
+ _URLs = {
40
+ "small": "https://os.unil.cloud.switch.ch/fma/fma_small.zip",
41
+ "metadata": "https://os.unil.cloud.switch.ch/fma/fma_metadata.zip",
42
+ }
43
+
44
+ class FMADataset(datasets.GeneratorBasedBuilder):
45
+ """FMA small dataset."""
46
+
47
+ VERSION = datasets.Version("1.0.0")
48
+
49
+ BUILDER_CONFIGS = [
50
+ datasets.BuilderConfig(name="small", version=VERSION, description="The small subset of FMA dataset"),
51
+ ]
52
+
53
+ def _info(self):
54
+ features = datasets.Features(
55
+ {
56
+ "track_id": datasets.Value("int32"),
57
+ "title": datasets.Value("string"),
58
+ "artist": datasets.Value("string"),
59
+ "genre": datasets.Value("string"),
60
+ "audio": datasets.Audio(sampling_rate=44100),
61
+ }
62
+ )
63
+ return datasets.DatasetInfo(
64
+ description=_DESCRIPTION,
65
+ features=features,
66
+ homepage=_HOMEPAGE,
67
+ license=_LICENSE,
68
+ citation=_CITATION,
69
+ )
70
+
71
+ def _split_generators(self, dl_manager):
72
+ """Returns SplitGenerators."""
73
+ data_dir = dl_manager.download_and_extract(_URLs)
74
+ return [
75
+ datasets.SplitGenerator(
76
+ name=datasets.Split.TRAIN,
77
+ gen_kwargs={
78
+ "filepath": os.path.join(data_dir["small"], "fma_small"),
79
+ "metadata_path": os.path.join(data_dir["metadata"], "fma_metadata"),
80
+ },
81
+ ),
82
+ ]
83
+
84
+ def _generate_examples(self, filepath, metadata_path):
85
+ """Yields examples."""
86
+ # Load metadata
87
+ tracks = pd.read_csv(os.path.join(metadata_path, "tracks.csv"), index_col=0, header=[0, 1])
88
+
89
+ # Iterate through audio files
90
+ for root, _, files in os.walk(filepath):
91
+ for file in files:
92
+ if file.endswith('.mp3'):
93
+ track_id = int(file.split('.')[0])
94
+ audio_path = os.path.join(root, file)
95
+
96
+ # Get metadata
97
+ title = tracks.loc[track_id, ('track', 'title')]
98
+ artist = tracks.loc[track_id, ('artist', 'name')]
99
+ genre = tracks.loc[track_id, ('track', 'genre_top')]
100
+
101
+ yield track_id, {
102
+ "track_id": track_id,
103
+ "title": title,
104
+ "artist": artist,
105
+ "genre": genre,
106
+ "audio": audio_path,
107
+ }
108
+
109
+ @property
110
+ def manual_download_instructions(self):
111
+ return """
112
+ To use the FMA dataset, you need to download it manually. Please follow these steps:
113
+
114
+ 1. Go to https://github.com/mdeff/fma
115
+ 2. Download the 'fma_small.zip' and 'fma_metadata.zip' files
116
+ 3. Extract both zip files
117
+ 4. Copy the 'fma_small' folder and the 'fma_metadata' folder to the root of this dataset repository
118
+
119
+ Once you have completed these steps, the dataset will be ready to use.
120
+ """ coding=utf-8
121
+ # Copyright 2024 The HuggingFace Datasets Authors and the current dataset script contributor.
122
+ #
123
+ # Licensed under the Apache License, Version 2.0 (the "License");
124
+ # you may not use this file except in compliance with the License.
125
+ # You may obtain a copy of the License at
126
+ #
127
+ # http://www.apache.org/licenses/LICENSE-2.0
128
+ #
129
+ # Unless required by applicable law or agreed to in writing, software
130
+ # distributed under the License is distributed on an "AS IS" BASIS,
131
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132
+ # See the License for the specific language governing permissions and
133
+ # limitations under the License.
134
+
135
+ import os
136
+ import pandas as pd
137
+ import numpy as np
138
+
139
+ import datasets
140
+
141
+ _CITATION = """
142
+ @inproceedings{defferrard2016fma,
143
+ title={FMA: A Dataset for Music Analysis},
144
+ author={Defferrard, Micha{\"e}l and Benzi, Kirell and Vandergheynst, Pierre and Bresson, Xavier},
145
+ booktitle={18th International Society for Music Information Retrieval Conference},
146
+ year={2017},
147
+ }
148
+ """
149
+
150
+ _DESCRIPTION = """
151
+ The Free Music Archive (FMA) is an open and easily accessible dataset of music collections.
152
+ """
153
+
154
+ _HOMEPAGE = "https://github.com/mdeff/fma"
155
+
156
+ _LICENSE = "Creative Commons Attribution 4.0 International License"
157
+
158
+ _URLs = {
159
+ "small": "https://os.unil.cloud.switch.ch/fma/fma_small.zip",
160
+ "metadata": "https://os.unil.cloud.switch.ch/fma/fma_metadata.zip",
161
+ }
162
+
163
+
164
+ class FMADataset(datasets.GeneratorBasedBuilder):
165
+ """FMA small dataset."""
166
+
167
+ VERSION = datasets.Version("1.0.0")
168
+
169
+ BUILDER_CONFIGS = [
170
+ datasets.BuilderConfig(name="small", version=VERSION, description="The small subset of FMA dataset"),
171
+ ]
172
+
173
+ def _info(self):
174
+ features = datasets.Features(
175
+ {
176
+ "track_id": datasets.Value("int32"),
177
+ "title": datasets.Value("string"),
178
+ "artist": datasets.Value("string"),
179
+ "genre": datasets.Value("string"),
180
+ "audio": datasets.Audio(sampling_rate=44100),
181
+ }
182
+ )
183
+ return datasets.DatasetInfo(
184
+ description=_DESCRIPTION,
185
+ features=features,
186
+ homepage=_HOMEPAGE,
187
+ license=_LICENSE,
188
+ citation=_CITATION,
189
+ )
190
+
191
+ def _split_generators(self, dl_manager):
192
+ """Returns SplitGenerators."""
193
+ data_dir = dl_manager.download_and_extract(_URLs)
194
+ return [
195
+ datasets.SplitGenerator(
196
+ name=datasets.Split.TRAIN,
197
+ gen_kwargs={
198
+ "filepath": os.path.join(data_dir["small"], "fma_small"),
199
+ "metadata_path": os.path.join(data_dir["metadata"], "fma_metadata"),
200
+ },
201
+ ),
202
+ ]
203
+
204
+ def _generate_examples(self, filepath, metadata_path):
205
+ """Yields examples."""
206
+ # Load metadata
207
+ tracks = pd.read_csv(os.path.join(metadata_path, "tracks.csv"), index_col=0, header=[0, 1])
208
+
209
+ # Iterate through audio files
210
+ for root, _, files in os.walk(filepath):
211
+ for file in files:
212
+ if file.endswith('.mp3'):
213
+ track_id = int(file.split('.')[0])
214
+ audio_path = os.path.join(root, file)
215
+
216
+ # Get metadata
217
+ title = tracks.loc[track_id, ('track', 'title')]
218
+ artist = tracks.loc[track_id, ('artist', 'name')]
219
+ genre = tracks.loc[track_id, ('track', 'genre_top')]
220
+
221
+ yield track_id, {
222
+ "track_id": track_id,
223
+ "title": title,
224
+ "artist": artist,
225
+ "genre": genre,
226
+ "audio": audio_path,
227
+ }