Syoy commited on
Commit
507730a
1 Parent(s): dc61846

modified config.splits form url

Browse files
Files changed (1) hide show
  1. dcase23-task2-enriched.py +38 -3
dcase23-task2-enriched.py CHANGED
@@ -3,6 +3,7 @@ import datasets
3
  import datasets.info
4
  import pandas as pd
5
  from pathlib import Path
 
6
  from datasets import load_dataset
7
  from typing import Iterable, Dict, Optional, Union, List
8
 
@@ -49,8 +50,16 @@ DATA_URLS = {
49
  "test": "data/dev_test.tar.gz",
50
  "metadata": "data/dev_metadata.csv",
51
  },
52
- "add": None,
53
- "eval": None,
 
 
 
 
 
 
 
 
54
  }
55
 
56
  STATS = {
@@ -105,7 +114,7 @@ class DCASE2023Task2DatasetConfig(datasets.BuilderConfig):
105
  f"Dataset for the DCASE 2023 Challenge Task 2 'First-Shot Unsupervised Anomalous Sound Detection "
106
  f"for Machine Condition Monitoring'. released on {self.release_date}. Original data available under"
107
  f"{self.homepage}. "
108
- f"SPLIT: {name}."
109
  )
110
  super(DCASE2023Task2DatasetConfig, self).__init__(
111
  name=name,
@@ -113,6 +122,27 @@ class DCASE2023Task2DatasetConfig(datasets.BuilderConfig):
113
  description=description,
114
  )
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
118
  """Dataset for the DCASE 2023 Challenge Task 2 "First-Shot Unsupervised Anomalous Sound Detection
@@ -214,3 +244,8 @@ class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
214
  result["path"] = path
215
  yield id_, {**result, "audio": audio}
216
  id_ += 1
 
 
 
 
 
 
3
  import datasets.info
4
  import pandas as pd
5
  from pathlib import Path
6
+ from renumics import spotlight
7
  from datasets import load_dataset
8
  from typing import Iterable, Dict, Optional, Union, List
9
 
 
50
  "test": "data/dev_test.tar.gz",
51
  "metadata": "data/dev_metadata.csv",
52
  },
53
+ "add": {
54
+ "train": "data/add_train.tar.gz",
55
+ "test": "data/add_test.tar.gz",
56
+ "metadata": "data/add_metadata.csv",
57
+ },
58
+ "eval": {
59
+ "train": "data/eval_train.tar.gz",
60
+ "test": "data/eval_test.tar.gz",
61
+ "metadata": "data/eval_metadata.csv",
62
+ },
63
  }
64
 
65
  STATS = {
 
114
  f"Dataset for the DCASE 2023 Challenge Task 2 'First-Shot Unsupervised Anomalous Sound Detection "
115
  f"for Machine Condition Monitoring'. released on {self.release_date}. Original data available under"
116
  f"{self.homepage}. "
117
+ f"CONFIG: {name}."
118
  )
119
  super(DCASE2023Task2DatasetConfig, self).__init__(
120
  name=name,
 
122
  description=description,
123
  )
124
 
125
+ def to_spotlight(self, data: Union[pd.DataFrame, datasets.Dataset]) -> pd.DataFrame:
126
+ if type(data) == datasets.Dataset:
127
+ df = data.to_pandas()
128
+ df["split"] = data.split
129
+ df["config"] = data.config_name
130
+
131
+ class_names = data.features["class"].names
132
+ df["class_name"] = df["class"].apply(lambda x: class_names[x])
133
+ elif type(data) == pd.DataFrame:
134
+ df = data
135
+ else:
136
+ raise TypeError("type(data) not in Union[pd.DataFrame, datasets.Dataset]")
137
+
138
+ df["file_path"] = df["path"]
139
+ df.rename(columns=self._rename, inplace=True)
140
+
141
+ return df.copy()
142
+
143
+ def get_layout(self):
144
+ return self._layout
145
+
146
 
147
  class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
148
  """Dataset for the DCASE 2023 Challenge Task 2 "First-Shot Unsupervised Anomalous Sound Detection
 
244
  result["path"] = path
245
  yield id_, {**result, "audio": audio}
246
  id_ += 1
247
+
248
+
249
+ if __name__ == "__main__":
250
+ ds = load_dataset("dcase23-task2-enriched.py", "dev", split="train", streaming=True)
251
+