Datasets:
admin
commited on
Commit
•
4cbd76f
1
Parent(s):
f986fe7
upl scripts
Browse files- .gitignore +1 -0
- README.md +210 -1
- pianos.py +258 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
rename.sh
|
README.md
CHANGED
@@ -1,3 +1,212 @@
|
|
1 |
---
|
2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: cc-by-nc-nd-4.0
|
3 |
+
task_categories:
|
4 |
+
- audio-classification
|
5 |
+
- image-classification
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
tags:
|
9 |
+
- music
|
10 |
+
- art
|
11 |
+
pretty_name: Piano Sound Quality Dataset
|
12 |
+
size_categories:
|
13 |
+
- 10K<n<100K
|
14 |
+
viewer: false
|
15 |
---
|
16 |
+
|
17 |
+
# Dataset Card for Piano Sound Quality Dataset
|
18 |
+
The raw dataset is sourced from the [Piano Sound Quality Dataset](https://ccmusic-database.github.io/en/database/ccm.html#shou1), which includes 12 full-range audio files in .wav/.mp3/.m4a format representing seven models of pianos: Kawai upright piano, Kawai grand piano, Young Change upright piano, Hsinghai upright piano, Grand Theatre Steinway piano, Steinway grand piano, and Pearl River upright piano. Additionally, there are 1,320 split monophonic audio files in .wav/.mp3/.m4a format, bringing the total number of files to 1,332. The dataset also includes a score sheet in .xls format containing subjective evaluations of piano sound quality provided by 29 participants with musical backgrounds.
|
19 |
+
|
20 |
+
Based on the aforementioned raw dataset, after data processing, we constructed the `default subset` of the current integrated version of the dataset, and its data structure can be viewed in the [viewer](https://www.modelscope.cn/datasets/ccmusic-database/pianos/dataPeview).
|
21 |
+
|
22 |
+
Due to the need to increase the dataset size and the absence of a popular piano brand, Yamaha, the `default subset` is expanded by recording an upright Yamaha piano into the `8_class subset`.
|
23 |
+
|
24 |
+
Since the current dataset has been validated by published articles, based on the `8_class subset`, we adopted the data processing method for dataset evaluation from the article and constructed the `eval subset`. Below is a brief introduction to the data structure of each subset.
|
25 |
+
|
26 |
+
## Dataset Structure
|
27 |
+
### Default Subset
|
28 |
+
<table class="pianos">
|
29 |
+
<tr>
|
30 |
+
<th>audio</th>
|
31 |
+
<th>mel</th>
|
32 |
+
<th>label (8-class)</th>
|
33 |
+
<th>pitch (88-class)</th>
|
34 |
+
</tr>
|
35 |
+
<tr>
|
36 |
+
<td>.wav, 44100Hz</td>
|
37 |
+
<td>.jpg, 44100Hz</td>
|
38 |
+
<td>PearlRiver / YoungChang / Steinway-T / Hsinghai / Kawai / Steinway / Kawai-G / Yamaha</td>
|
39 |
+
<td>88 pitches on piano</td>
|
40 |
+
</tr>
|
41 |
+
<tr>
|
42 |
+
<td>...</td>
|
43 |
+
<td>...</td>
|
44 |
+
<td>...</td>
|
45 |
+
<td>...</td>
|
46 |
+
</tr>
|
47 |
+
</table>
|
48 |
+
|
49 |
+
### Eval Subset
|
50 |
+
<style>
|
51 |
+
.pianos td {
|
52 |
+
vertical-align: middle !important;
|
53 |
+
text-align: center;
|
54 |
+
}
|
55 |
+
.pianos th {
|
56 |
+
text-align: center;
|
57 |
+
}
|
58 |
+
</style>
|
59 |
+
<table class="pianos">
|
60 |
+
<tr>
|
61 |
+
<th>mel</th>
|
62 |
+
<th>label (8-class)</th>
|
63 |
+
<th>pitch (88-class)</th>
|
64 |
+
</tr>
|
65 |
+
<tr>
|
66 |
+
<td>.jpg, 0.18s 44100Hz</td>
|
67 |
+
<td>PearlRiver / YoungChang / Steinway-T / Hsinghai / Kawai / Steinway / Kawai-G / Yamaha</td>
|
68 |
+
<td>88 pitches on piano</td>
|
69 |
+
</tr>
|
70 |
+
<tr>
|
71 |
+
<td>...</td>
|
72 |
+
<td>...</td>
|
73 |
+
<td>...</td>
|
74 |
+
</tr>
|
75 |
+
</table>
|
76 |
+
|
77 |
+
<img src="https://www.modelscope.cn/api/v1/datasets/ccmusic-database/pianos/repo?Revision=master&FilePath=.%2Fdata%2Fpiano.png&View=true">
|
78 |
+
|
79 |
+
### Data Instances
|
80 |
+
.zip(.wav, jpg)
|
81 |
+
|
82 |
+
### Data Fields
|
83 |
+
```
|
84 |
+
1_PearlRiver
|
85 |
+
2_YoungChang
|
86 |
+
3_Steinway-T
|
87 |
+
4_Hsinghai
|
88 |
+
5_Kawai
|
89 |
+
6_Steinway
|
90 |
+
7_Kawai-G
|
91 |
+
8_Yamaha (For Non-default subset)
|
92 |
+
```
|
93 |
+
|
94 |
+
### Data Splits for Eval Subset
|
95 |
+
| Split | Default | 8_class | Eval |
|
96 |
+
| :---------------: | :------------------: | :-----------------: | :-----------------: |
|
97 |
+
| train(80%) | 461 | 531 | 14678 |
|
98 |
+
| validation(10%) | 59 | 68 | 1835 |
|
99 |
+
| test(10%) | 60 | 69 | 1839 |
|
100 |
+
| total | 580 | 668 | 18352 |
|
101 |
+
| Total duration(s) | `2851.6933333333354` | `3247.941395833335` | `3247.941395833335` |
|
102 |
+
|
103 |
+
## Viewer
|
104 |
+
<https://www.modelscope.cn/datasets/ccmusic-database/pianos/dataPeview>
|
105 |
+
|
106 |
+
## Usage
|
107 |
+
### Default Subset
|
108 |
+
```python
|
109 |
+
from datasets import load_dataset
|
110 |
+
|
111 |
+
ds = load_dataset("ccmusic-database/pianos", name="default")
|
112 |
+
for item in ds["train"]:
|
113 |
+
print(item)
|
114 |
+
|
115 |
+
for item in ds["validation"]:
|
116 |
+
print(item)
|
117 |
+
|
118 |
+
for item in ds["test"]:
|
119 |
+
print(item)
|
120 |
+
```
|
121 |
+
|
122 |
+
### Eval Subset
|
123 |
+
```python
|
124 |
+
from datasets import load_dataset
|
125 |
+
|
126 |
+
ds = load_dataset("ccmusic-database/pianos", name="eval")
|
127 |
+
for item in ds["train"]:
|
128 |
+
print(item)
|
129 |
+
|
130 |
+
for item in ds["validation"]:
|
131 |
+
print(item)
|
132 |
+
|
133 |
+
for item in ds["test"]:
|
134 |
+
print(item)
|
135 |
+
```
|
136 |
+
|
137 |
+
## Maintenance
|
138 |
+
```bash
|
139 |
+
GIT_LFS_SKIP_SMUDGE=1 git clone git@hf.co:datasets/ccmusic-database/pianos
|
140 |
+
cd pianos
|
141 |
+
```
|
142 |
+
|
143 |
+
## Dataset Description
|
144 |
+
- **Homepage:** <https://ccmusic-database.github.io>
|
145 |
+
- **Repository:** <https://huggingface.co/datasets/CCMUSIC/pianos>
|
146 |
+
- **Paper:** <https://doi.org/10.5281/zenodo.5676893>
|
147 |
+
- **Leaderboard:** <https://www.modelscope.cn/datasets/ccmusic/pianos>
|
148 |
+
- **Point of Contact:** <https://arxiv.org/abs/2310.04722>
|
149 |
+
|
150 |
+
### Dataset Summary
|
151 |
+
Due to the need to increase the dataset size and the absence of a popular piano brand, Yamaha, the dataset is expanded by recording an upright Yamaha piano in [[1]](https://arxiv.org/pdf/2310.04722.pdf), in which the recording details can be found. This results in a total of 2,020 audio files. As models used in that article require a larger dataset, data augmentation was performed. The original audio was transformed into Mel spectrograms and sliced into 0.18-second segments, a parameter chosen based on empirical experience. This results in 18,745 spectrogram slices. Although 0.18 seconds may seem narrow, this duration is sufficient for the task at hand, as the classification of piano sound quality does not heavily rely on the temporal characteristics of the audio segments.
|
152 |
+
|
153 |
+
### Supported Tasks and Leaderboards
|
154 |
+
Piano Sound Classification, pitch detection
|
155 |
+
|
156 |
+
### Languages
|
157 |
+
English
|
158 |
+
|
159 |
+
## Dataset Creation
|
160 |
+
### Curation Rationale
|
161 |
+
Lack of a dataset for piano sound quality
|
162 |
+
|
163 |
+
### Source Data
|
164 |
+
#### Initial Data Collection and Normalization
|
165 |
+
Zhaorui Liu, Shaohua Ji, Monan Zhou
|
166 |
+
#### Who are the source language producers?
|
167 |
+
Students from CCMUSIC & CCOM
|
168 |
+
|
169 |
+
### Annotations
|
170 |
+
#### Annotation process
|
171 |
+
Students from CCMUSIC recorded different piano sounds and labeled them, and then a subjective survey of sound quality was conducted to score them.
|
172 |
+
|
173 |
+
#### Who are the annotators?
|
174 |
+
Students from CCMUSIC & CCOM
|
175 |
+
|
176 |
+
### Personal and Sensitive Information
|
177 |
+
Piano brands
|
178 |
+
|
179 |
+
## Considerations for Using the Data
|
180 |
+
### Social Impact of Dataset
|
181 |
+
Help develop piano sound quality scoring apps
|
182 |
+
|
183 |
+
### Discussion of Biases
|
184 |
+
Only for pianos
|
185 |
+
|
186 |
+
### Other Known Limitations
|
187 |
+
Lack of black keys for Steinway, data imbalance
|
188 |
+
|
189 |
+
## Additional Information
|
190 |
+
### Dataset Curators
|
191 |
+
Zijin Li
|
192 |
+
|
193 |
+
### Evaluation
|
194 |
+
[1] [Monan Zhou, Shangda Wu, Shaohua Ji, Zijin Li, and Wei Li. A Holistic Evaluation of Piano Sound Quality[C]//Proceedings of the 10th Conference on Sound and Music Technology (CSMT). Springer, Singapore, 2023.](https://arxiv.org/pdf/2310.04722.pdf)
|
195 |
+
|
196 |
+
(Note: this paper only uses the first 7 piano classes in the dataset, its future work has finished the 8-class evaluation)
|
197 |
+
|
198 |
+
### Citation Information
|
199 |
+
```bibtex
|
200 |
+
@dataset{zhaorui_liu_2021_5676893,
|
201 |
+
author = {Monan Zhou, Shenyang Xu, Zhaorui Liu, Zhaowen Wang, Feng Yu, Wei Li and Baoqiang Han},
|
202 |
+
title = {CCMusic: an Open and Diverse Database for Chinese and General Music Information Retrieval Research},
|
203 |
+
month = {mar},
|
204 |
+
year = {2024},
|
205 |
+
publisher = {HuggingFace},
|
206 |
+
version = {1.2},
|
207 |
+
url = {https://huggingface.co/ccmusic-database}
|
208 |
+
}
|
209 |
+
```
|
210 |
+
|
211 |
+
### Contributions
|
212 |
+
Provide a dataset for piano sound quality
|
pianos.py
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import random
|
3 |
+
import datasets
|
4 |
+
from datasets.tasks import ImageClassification
|
5 |
+
|
6 |
+
|
7 |
+
_NAMES = {
|
8 |
+
"PearlRiver": [2.33, 2.53, 2.37, 2.41],
|
9 |
+
"YoungChang": [2.53, 2.63, 2.97, 2.71],
|
10 |
+
"Steinway-T": [3.6, 3.63, 3.67, 3.63],
|
11 |
+
"Hsinghai": [3.4, 3.27, 3.2, 3.29],
|
12 |
+
"Kawai": [3.17, 2.5, 2.93, 2.87],
|
13 |
+
"Steinway": [4.23, 3.67, 4, 3.97],
|
14 |
+
"Kawai-G": [3.37, 2.97, 3.07, 3.14],
|
15 |
+
"Yamaha": [3.23, 3.03, 3.17, 3.14],
|
16 |
+
}
|
17 |
+
|
18 |
+
_DBNAME = os.path.basename(__file__).split(".")[0]
|
19 |
+
|
20 |
+
_HOMEPAGE = f"https://www.modelscope.cn/datasets/ccmusic-database/{_DBNAME}"
|
21 |
+
|
22 |
+
_DOMAIN = f"https://www.modelscope.cn/api/v1/datasets/ccmusic-database/{_DBNAME}/repo?Revision=master&FilePath=data"
|
23 |
+
|
24 |
+
|
25 |
+
_PITCHES = {
|
26 |
+
"009": "A2",
|
27 |
+
"010": "A2#/B2b",
|
28 |
+
"011": "B2",
|
29 |
+
"100": "C1",
|
30 |
+
"101": "C1#/D1b",
|
31 |
+
"102": "D1",
|
32 |
+
"103": "D1#/E1b",
|
33 |
+
"104": "E1",
|
34 |
+
"105": "F1",
|
35 |
+
"106": "F1#/G1b",
|
36 |
+
"107": "G1",
|
37 |
+
"108": "G1#/A1b",
|
38 |
+
"109": "A1",
|
39 |
+
"110": "A1#/B1b",
|
40 |
+
"111": "B1",
|
41 |
+
"200": "C",
|
42 |
+
"201": "C#/Db",
|
43 |
+
"202": "D",
|
44 |
+
"203": "D#/Eb",
|
45 |
+
"204": "E",
|
46 |
+
"205": "F",
|
47 |
+
"206": "F#/Gb",
|
48 |
+
"207": "G",
|
49 |
+
"208": "G#/Ab",
|
50 |
+
"209": "A",
|
51 |
+
"210": "A#/Bb",
|
52 |
+
"211": "B",
|
53 |
+
"300": "c",
|
54 |
+
"301": "c#/db",
|
55 |
+
"302": "d",
|
56 |
+
"303": "d#/eb",
|
57 |
+
"304": "e",
|
58 |
+
"305": "f",
|
59 |
+
"306": "f#/gb",
|
60 |
+
"307": "g",
|
61 |
+
"308": "g#/ab",
|
62 |
+
"309": "a",
|
63 |
+
"310": "a#/bb",
|
64 |
+
"311": "b",
|
65 |
+
"400": "c1",
|
66 |
+
"401": "c1#/d1b",
|
67 |
+
"402": "d1",
|
68 |
+
"403": "d1#/e1b",
|
69 |
+
"404": "e1",
|
70 |
+
"405": "f1",
|
71 |
+
"406": "f1#/g1b",
|
72 |
+
"407": "g1",
|
73 |
+
"408": "g1#/a1b",
|
74 |
+
"409": "a1",
|
75 |
+
"410": "a1#/b1b",
|
76 |
+
"411": "b1",
|
77 |
+
"500": "c2",
|
78 |
+
"501": "c2#/d2b",
|
79 |
+
"502": "d2",
|
80 |
+
"503": "d2#/e2b",
|
81 |
+
"504": "e2",
|
82 |
+
"505": "f2",
|
83 |
+
"506": "f2#/g2b",
|
84 |
+
"507": "g2",
|
85 |
+
"508": "g2#/a2b",
|
86 |
+
"509": "a2",
|
87 |
+
"510": "a2#/b2b",
|
88 |
+
"511": "b2",
|
89 |
+
"600": "c3",
|
90 |
+
"601": "c3#/d3b",
|
91 |
+
"602": "d3",
|
92 |
+
"603": "d3#/e3b",
|
93 |
+
"604": "e3",
|
94 |
+
"605": "f3",
|
95 |
+
"606": "f3#/g3b",
|
96 |
+
"607": "g3",
|
97 |
+
"608": "g3#/a3b",
|
98 |
+
"609": "a3",
|
99 |
+
"610": "a3#/b3b",
|
100 |
+
"611": "b3",
|
101 |
+
"700": "c4",
|
102 |
+
"701": "c4#/d4b",
|
103 |
+
"702": "d4",
|
104 |
+
"703": "d4#/e4b",
|
105 |
+
"704": "e4",
|
106 |
+
"705": "f4",
|
107 |
+
"706": "f4#/g4b",
|
108 |
+
"707": "g4",
|
109 |
+
"708": "g4#/a4b",
|
110 |
+
"709": "a4",
|
111 |
+
"710": "a4#/b4b",
|
112 |
+
"711": "b4",
|
113 |
+
"800": "c5",
|
114 |
+
}
|
115 |
+
|
116 |
+
_URLS = {
|
117 |
+
"audio": f"{_DOMAIN}/audio.zip",
|
118 |
+
"mel": f"{_DOMAIN}/mel.zip",
|
119 |
+
"eval": f"{_DOMAIN}/eval.zip",
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
class pianos(datasets.GeneratorBasedBuilder):
|
124 |
+
def _info(self):
|
125 |
+
names = list(_NAMES.keys())
|
126 |
+
if self.config.name == "default":
|
127 |
+
names = names[:-1]
|
128 |
+
|
129 |
+
return datasets.DatasetInfo(
|
130 |
+
features=(
|
131 |
+
datasets.Features(
|
132 |
+
{
|
133 |
+
"audio": datasets.Audio(sampling_rate=44100),
|
134 |
+
"mel": datasets.Image(),
|
135 |
+
"label": datasets.features.ClassLabel(names=names),
|
136 |
+
"pitch": datasets.features.ClassLabel(
|
137 |
+
names=list(_PITCHES.values())
|
138 |
+
),
|
139 |
+
"bass_score": datasets.Value("float32"),
|
140 |
+
"mid_score": datasets.Value("float32"),
|
141 |
+
"treble_score": datasets.Value("float32"),
|
142 |
+
"avg_score": datasets.Value("float32"),
|
143 |
+
}
|
144 |
+
)
|
145 |
+
if self.config.name != "eval"
|
146 |
+
else datasets.Features(
|
147 |
+
{
|
148 |
+
"mel": datasets.Image(),
|
149 |
+
"label": datasets.features.ClassLabel(names=names),
|
150 |
+
"pitch": datasets.features.ClassLabel(
|
151 |
+
names=list(_PITCHES.values())
|
152 |
+
),
|
153 |
+
"bass_score": datasets.Value("float32"),
|
154 |
+
"mid_score": datasets.Value("float32"),
|
155 |
+
"treble_score": datasets.Value("float32"),
|
156 |
+
"avg_score": datasets.Value("float32"),
|
157 |
+
}
|
158 |
+
)
|
159 |
+
),
|
160 |
+
homepage=_HOMEPAGE,
|
161 |
+
license="CC-BY-NC-ND",
|
162 |
+
version="1.2.0",
|
163 |
+
supervised_keys=("mel", "label"),
|
164 |
+
task_templates=ImageClassification(
|
165 |
+
image_column="mel",
|
166 |
+
label_column="label",
|
167 |
+
),
|
168 |
+
)
|
169 |
+
|
170 |
+
def _split_generators(self, dl_manager):
|
171 |
+
dataset = []
|
172 |
+
if self.config.name != "eval":
|
173 |
+
subset = {}
|
174 |
+
audio_files = dl_manager.download_and_extract(_URLS["audio"])
|
175 |
+
for path in dl_manager.iter_files([audio_files]):
|
176 |
+
fname = os.path.basename(path)
|
177 |
+
if fname.endswith(".wav"):
|
178 |
+
lebal = os.path.basename(os.path.dirname(path))
|
179 |
+
if self.config.name == "default" and lebal == "Yamaha":
|
180 |
+
continue
|
181 |
+
|
182 |
+
subset[fname.split(".")[0]] = {
|
183 |
+
"audio": path,
|
184 |
+
"label": lebal,
|
185 |
+
"pitch": _PITCHES[fname[1:4]],
|
186 |
+
"bass_score": _NAMES[lebal][0],
|
187 |
+
"mid_score": _NAMES[lebal][1],
|
188 |
+
"treble_score": _NAMES[lebal][2],
|
189 |
+
"avg_score": _NAMES[lebal][3],
|
190 |
+
}
|
191 |
+
|
192 |
+
mel_files = dl_manager.download_and_extract(_URLS["mel"])
|
193 |
+
for path in dl_manager.iter_files([mel_files]):
|
194 |
+
fname = os.path.basename(path)
|
195 |
+
pname = fname.split(".")[0]
|
196 |
+
if fname.endswith(".jpg") and pname in subset:
|
197 |
+
subset[pname]["mel"] = path
|
198 |
+
|
199 |
+
dataset = list(subset.values())
|
200 |
+
|
201 |
+
else:
|
202 |
+
data_files = dl_manager.download_and_extract(_URLS["eval"])
|
203 |
+
for path in dl_manager.iter_files([data_files]):
|
204 |
+
fname: str = os.path.basename(path)
|
205 |
+
if fname.endswith(".jpg"):
|
206 |
+
lebal = os.path.basename(os.path.dirname(path))
|
207 |
+
dataset.append(
|
208 |
+
{
|
209 |
+
"mel": path,
|
210 |
+
"label": lebal,
|
211 |
+
"pitch": _PITCHES[fname.split("_")[0]],
|
212 |
+
"bass_score": _NAMES[lebal][0],
|
213 |
+
"mid_score": _NAMES[lebal][1],
|
214 |
+
"treble_score": _NAMES[lebal][2],
|
215 |
+
"avg_score": _NAMES[lebal][3],
|
216 |
+
}
|
217 |
+
)
|
218 |
+
|
219 |
+
names = list(_NAMES.keys())
|
220 |
+
if self.config.name == "default":
|
221 |
+
names = names[:-1]
|
222 |
+
|
223 |
+
categories = {}
|
224 |
+
for name in names:
|
225 |
+
categories[name] = []
|
226 |
+
|
227 |
+
for data in dataset:
|
228 |
+
categories[data["label"]].append(data)
|
229 |
+
|
230 |
+
testset, validset, trainset = [], [], []
|
231 |
+
for cls in categories:
|
232 |
+
random.shuffle(categories[cls])
|
233 |
+
count = len(categories[cls])
|
234 |
+
p80 = int(count * 0.8)
|
235 |
+
p90 = int(count * 0.9)
|
236 |
+
trainset += categories[cls][:p80]
|
237 |
+
validset += categories[cls][p80:p90]
|
238 |
+
testset += categories[cls][p90:]
|
239 |
+
|
240 |
+
random.shuffle(trainset)
|
241 |
+
random.shuffle(validset)
|
242 |
+
random.shuffle(testset)
|
243 |
+
|
244 |
+
return [
|
245 |
+
datasets.SplitGenerator(
|
246 |
+
name=datasets.Split.TRAIN, gen_kwargs={"files": trainset}
|
247 |
+
),
|
248 |
+
datasets.SplitGenerator(
|
249 |
+
name=datasets.Split.VALIDATION, gen_kwargs={"files": validset}
|
250 |
+
),
|
251 |
+
datasets.SplitGenerator(
|
252 |
+
name=datasets.Split.TEST, gen_kwargs={"files": testset}
|
253 |
+
),
|
254 |
+
]
|
255 |
+
|
256 |
+
def _generate_examples(self, files):
|
257 |
+
for i, path in enumerate(files):
|
258 |
+
yield i, path
|