Update dcase23-task2-enriched.py
Browse files- dcase23-task2-enriched.py +18 -0
dcase23-task2-enriched.py
CHANGED
@@ -96,6 +96,24 @@ class DCASE2023Task2DatasetConfig(datasets.BuilderConfig):
|
|
96 |
description=description,
|
97 |
)
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
|
101 |
"""Dataset for the DCASE 2023 Challenge Task 2 "First-Shot Unsupervised Anomalous Sound Detection
|
|
|
96 |
description=description,
|
97 |
)
|
98 |
|
99 |
+
def to_spotlight(self, data: Union[pd.DataFrame, datasets.Dataset]) -> pd.DataFrame:
|
100 |
+
if type(data) == datasets.Dataset:
|
101 |
+
df = data.to_pandas()
|
102 |
+
df["split"] = data.split
|
103 |
+
df["config"] = data.config_name
|
104 |
+
|
105 |
+
class_names = data.features["class"].names
|
106 |
+
df["class_name"] = df["class"].apply(lambda x: class_names[x])
|
107 |
+
elif type(data) == pd.DataFrame:
|
108 |
+
df = data
|
109 |
+
else:
|
110 |
+
raise TypeError("type(data) not in Union[pd.DataFrame, datasets.Dataset]")
|
111 |
+
|
112 |
+
df["file_path"] = df["path"]
|
113 |
+
df.rename(columns=self.rename, inplace=True)
|
114 |
+
|
115 |
+
return df.copy()
|
116 |
+
|
117 |
|
118 |
class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
|
119 |
"""Dataset for the DCASE 2023 Challenge Task 2 "First-Shot Unsupervised Anomalous Sound Detection
|