Datasets:
Size:
10K<n<100K
License:
MuGeminorum
commited on
Commit
•
1bf45da
1
Parent(s):
47b3773
add 2 spects
Browse files- data/chroma.zip +3 -0
- data/cqt.zip +3 -0
- music_genre.py +37 -43
data/chroma.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eb6bb316d1fd7cd43737f30fba0aeaa81475daaa8f0b0e2c56b341e69465209b
|
3 |
+
size 1424507306
|
data/cqt.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eb6bb316d1fd7cd43737f30fba0aeaa81475daaa8f0b0e2c56b341e69465209b
|
3 |
+
size 1424507306
|
music_genre.py
CHANGED
@@ -55,7 +55,11 @@ This database contains about 1700 musical pieces (.mp3 format)
|
|
55 |
with lengths of 270-300s that are divided into 17 genres in total.
|
56 |
"""
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
59 |
|
60 |
|
61 |
class music_genre(datasets.GeneratorBasedBuilder):
|
@@ -84,49 +88,39 @@ class music_genre(datasets.GeneratorBasedBuilder):
|
|
84 |
)
|
85 |
|
86 |
def _split_generators(self, dl_manager):
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
"files": dataset[p80:p90]
|
111 |
-
},
|
112 |
-
),
|
113 |
-
datasets.SplitGenerator(
|
114 |
-
name=datasets.Split.TEST,
|
115 |
-
gen_kwargs={
|
116 |
-
"files": dataset[p90:]
|
117 |
-
},
|
118 |
-
),
|
119 |
-
]
|
120 |
|
121 |
def _calc_label(self, path, depth, substr='/mel/'):
|
122 |
-
|
123 |
dirpath = os.path.dirname(path)
|
124 |
-
substr_index = dirpath.find(
|
125 |
if substr_index < 0:
|
126 |
-
|
127 |
-
substr_index = dirpath.find(
|
128 |
|
129 |
-
labstr = dirpath[substr_index + len(
|
130 |
labs = labstr.split('/')
|
131 |
if len(labs) < 2:
|
132 |
labs = labstr.split('\\')
|
@@ -136,11 +130,11 @@ class music_genre(datasets.GeneratorBasedBuilder):
|
|
136 |
else:
|
137 |
return 0
|
138 |
|
139 |
-
def _generate_examples(self, files):
|
140 |
for i, path in enumerate(files):
|
141 |
yield i, {
|
142 |
"mel": path,
|
143 |
-
"fst_level_label": _NAMES_1[self._calc_label(path, 1)],
|
144 |
-
"sec_level_label": _NAMES_2[self._calc_label(path, 2)],
|
145 |
-
"thr_level_label": _NAMES_3[self._calc_label(path, 3)]
|
146 |
}
|
|
|
55 |
with lengths of 270-300s that are divided into 17 genres in total.
|
56 |
"""
|
57 |
|
58 |
+
_URLS = {
|
59 |
+
"mel": _HOMEPAGE + "/resolve/main/data/mel.zip",
|
60 |
+
"cqt": _HOMEPAGE + "/resolve/main/data/cqt.zip",
|
61 |
+
"chroma": _HOMEPAGE + "/resolve/main/data/chroma.zip"
|
62 |
+
}
|
63 |
|
64 |
|
65 |
class music_genre(datasets.GeneratorBasedBuilder):
|
|
|
88 |
)
|
89 |
|
90 |
def _split_generators(self, dl_manager):
|
91 |
+
splits = []
|
92 |
+
for spect in _URLS.keys():
|
93 |
+
data_files = dl_manager.download_and_extract(_URLS[spect])
|
94 |
+
files = dl_manager.iter_files([data_files])
|
95 |
+
|
96 |
+
dataset = []
|
97 |
+
for path in files:
|
98 |
+
if os.path.basename(path).endswith(".jpg"):
|
99 |
+
dataset.append(path)
|
100 |
+
|
101 |
+
random.shuffle(dataset)
|
102 |
+
|
103 |
+
splits.append(
|
104 |
+
datasets.SplitGenerator(
|
105 |
+
name=spect,
|
106 |
+
gen_kwargs={
|
107 |
+
"files": dataset,
|
108 |
+
"spect": f"/{spect}/"
|
109 |
+
}
|
110 |
+
)
|
111 |
+
)
|
112 |
+
|
113 |
+
return splits
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
def _calc_label(self, path, depth, substr='/mel/'):
|
116 |
+
spect = substr
|
117 |
dirpath = os.path.dirname(path)
|
118 |
+
substr_index = dirpath.find(spect)
|
119 |
if substr_index < 0:
|
120 |
+
spect = spect.replace('/', '\\')
|
121 |
+
substr_index = dirpath.find(spect)
|
122 |
|
123 |
+
labstr = dirpath[substr_index + len(spect):]
|
124 |
labs = labstr.split('/')
|
125 |
if len(labs) < 2:
|
126 |
labs = labstr.split('\\')
|
|
|
130 |
else:
|
131 |
return 0
|
132 |
|
133 |
+
def _generate_examples(self, files, spect):
|
134 |
for i, path in enumerate(files):
|
135 |
yield i, {
|
136 |
"mel": path,
|
137 |
+
"fst_level_label": _NAMES_1[self._calc_label(path, 1, spect)],
|
138 |
+
"sec_level_label": _NAMES_2[self._calc_label(path, 2, spect)],
|
139 |
+
"thr_level_label": _NAMES_3[self._calc_label(path, 3, spect)]
|
140 |
}
|