Datasets:
Tasks:
Audio Classification
Modalities:
Audio
Languages:
English
Tags:
audio
music-classification
meter-classification
multi-class-classification
multi-label-classification
License:
Add files using upload-large-folder tool
Browse files- meter2800.py +17 -21
meter2800.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from pathlib import Path
|
2 |
import datasets
|
3 |
import pandas as pd
|
@@ -18,6 +20,7 @@ Each audio file is annotated with a primary meter class label and an alternative
|
|
18 |
It is split into training, validation, and test sets, each available in two class configurations:
|
19 |
2-class and 4-class. All audio is 16-bit WAV format.
|
20 |
"""
|
|
|
21 |
_HOMEPAGE = "https://huggingface.co/datasets/pianistprogrammer/Meter2800"
|
22 |
_LICENSE = "mit"
|
23 |
|
@@ -53,38 +56,31 @@ class Meter2800(datasets.GeneratorBasedBuilder):
|
|
53 |
)
|
54 |
|
55 |
def _split_generators(self, dl_manager):
|
56 |
-
|
57 |
-
csv_files = dl_manager.download({
|
58 |
split: f"https://huggingface.co/datasets/pianistprogrammer/Meter2800/resolve/main/data_{split}_{self.config.name}.csv"
|
59 |
for split in ["train", "val", "test"]
|
60 |
-
}
|
61 |
-
|
|
|
|
|
|
|
62 |
|
63 |
return [
|
64 |
-
datasets.SplitGenerator(
|
65 |
-
|
66 |
-
|
67 |
-
),
|
68 |
-
datasets.SplitGenerator(
|
69 |
-
name=datasets.Split.VALIDATION,
|
70 |
-
gen_kwargs={"csv_path": csv_files["val"], "root": archive}
|
71 |
-
),
|
72 |
-
datasets.SplitGenerator(
|
73 |
-
name=datasets.Split.TEST,
|
74 |
-
gen_kwargs={"csv_path": csv_files["test"], "root": archive}
|
75 |
-
),
|
76 |
]
|
77 |
|
78 |
def _generate_examples(self, csv_path, root):
|
79 |
df = pd.read_csv(csv_path).dropna(subset=["filename", "label", "meter"]).reset_index(drop=True)
|
80 |
-
|
81 |
for idx, row in df.iterrows():
|
82 |
-
rel = row["filename"].lstrip("/") #
|
83 |
-
|
84 |
-
|
|
|
85 |
yield idx, {
|
86 |
"filename": rel,
|
87 |
-
"audio": str(
|
88 |
"label": row["label"],
|
89 |
"meter": str(row["meter"]),
|
90 |
"alt_meter": str(row.get("alt_meter", row["meter"])),
|
|
|
1 |
+
# meter2800.py
|
2 |
+
|
3 |
from pathlib import Path
|
4 |
import datasets
|
5 |
import pandas as pd
|
|
|
20 |
It is split into training, validation, and test sets, each available in two class configurations:
|
21 |
2-class and 4-class. All audio is 16-bit WAV format.
|
22 |
"""
|
23 |
+
|
24 |
_HOMEPAGE = "https://huggingface.co/datasets/pianistprogrammer/Meter2800"
|
25 |
_LICENSE = "mit"
|
26 |
|
|
|
56 |
)
|
57 |
|
58 |
def _split_generators(self, dl_manager):
|
59 |
+
csv_links = {
|
|
|
60 |
split: f"https://huggingface.co/datasets/pianistprogrammer/Meter2800/resolve/main/data_{split}_{self.config.name}.csv"
|
61 |
for split in ["train", "val", "test"]
|
62 |
+
}
|
63 |
+
csv_files = dl_manager.download(csv_links)
|
64 |
+
archive = dl_manager.download_and_extract(
|
65 |
+
"https://huggingface.co/datasets/pianistprogrammer/Meter2800/resolve/main/data.tar.gz"
|
66 |
+
)
|
67 |
|
68 |
return [
|
69 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"csv_path": csv_files["train"], "root": archive}),
|
70 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"csv_path": csv_files["val"], "root": archive}),
|
71 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"csv_path": csv_files["test"], "root": archive}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
]
|
73 |
|
74 |
def _generate_examples(self, csv_path, root):
|
75 |
df = pd.read_csv(csv_path).dropna(subset=["filename", "label", "meter"]).reset_index(drop=True)
|
|
|
76 |
for idx, row in df.iterrows():
|
77 |
+
rel = row["filename"].lstrip("/") # ensure relative path, not absolute
|
78 |
+
audio_path = Path(root) / rel
|
79 |
+
if not audio_path.is_file():
|
80 |
+
raise FileNotFoundError(f"Missing audio file: {audio_path}")
|
81 |
yield idx, {
|
82 |
"filename": rel,
|
83 |
+
"audio": str(audio_path),
|
84 |
"label": row["label"],
|
85 |
"meter": str(row["meter"]),
|
86 |
"alt_meter": str(row.get("alt_meter", row["meter"])),
|