Syoy commited on
Commit
2e38ec0
1 Parent(s): 18d8d1c

added import

Browse files
Files changed (1) hide show
  1. dcase23-task2-enriched.py +6 -11
dcase23-task2-enriched.py CHANGED
@@ -6,6 +6,7 @@ import numpy as np
6
  from pathlib import Path
7
  from datasets import load_dataset
8
  from typing import Iterable, Dict, Optional, Union, List
 
9
 
10
 
11
  _CITATION = """\
@@ -114,12 +115,6 @@ DATASET = {
114
  'eval': 'DCASE 2023 Challenge Task 2 Evaluation Dataset',
115
  }
116
 
117
- _SPOTLIGHT_LAYOUT = "data/config-spotlight-layout.json"
118
-
119
- _SPOTLIGHT_RENAME = {
120
- "audio": "original_audio",
121
- "path": "audio",
122
- }
123
 
124
 
125
  class DCASE2023Task2DatasetConfig(datasets.BuilderConfig):
@@ -133,7 +128,6 @@ class DCASE2023Task2DatasetConfig(datasets.BuilderConfig):
133
  self.splits = kwargs.pop("splits", None)
134
  self.rename = kwargs.pop("rename", None)
135
  self.layout = kwargs.pop("layout", None)
136
- self._layout = None
137
  description = (
138
  f"Dataset for the DCASE 2023 Challenge Task 2 'First-Shot Unsupervised Anomalous Sound Detection "
139
  f"for Machine Condition Monitoring'. released on {self.release_date}. Original data available under"
@@ -189,11 +183,12 @@ class DCASE2023Task2DatasetConfig(datasets.BuilderConfig):
189
 
190
  return df.copy()
191
 
192
- def get_layout(self):
193
- if not self._layout:
194
- self._layout = datasets.DownloadManager().download(self.layout)
 
195
 
196
- return self._layout
197
 
198
 
199
 
 
6
  from pathlib import Path
7
  from datasets import load_dataset
8
  from typing import Iterable, Dict, Optional, Union, List
9
+ from .spotlight_config import SPOTLIGHT_LAYOUTS, SPOTLIGHT_RENAME
10
 
11
 
12
  _CITATION = """\
 
115
  'eval': 'DCASE 2023 Challenge Task 2 Evaluation Dataset',
116
  }
117
 
 
 
 
 
 
 
118
 
119
 
120
  class DCASE2023Task2DatasetConfig(datasets.BuilderConfig):
 
128
  self.splits = kwargs.pop("splits", None)
129
  self.rename = kwargs.pop("rename", None)
130
  self.layout = kwargs.pop("layout", None)
 
131
  description = (
132
  f"Dataset for the DCASE 2023 Challenge Task 2 'First-Shot Unsupervised Anomalous Sound Detection "
133
  f"for Machine Condition Monitoring'. released on {self.release_date}. Original data available under"
 
183
 
184
  return df.copy()
185
 
186
+ def get_layout(self, config: str = "standard") -> str:
187
+ layout_json = tempfile.mktemp()
188
+ with open(layout_json, "w") as outfile:
189
+ json.dump(self.layout[config], outfile)
190
 
191
+ return layout_json
192
 
193
 
194