Syoy commited on
Commit
be18565
1 Parent(s): 5b3d915

updated readme

Browse files
Files changed (4) hide show
  1. .gitattributes +15 -0
  2. 7690148_urls.txt +7 -0
  3. README.md +24 -22
  4. dcase23-task2-enriched.py +46 -55
.gitattributes CHANGED
@@ -58,3 +58,18 @@ data/MIT_ast-finetuned-audioset-10-10-0-4593-embeddings_dev_train.npz filter=lfs
58
  data/MIT_ast-finetuned-audioset-10-10-0-4593-embeddings_dev_test.npz filter=lfs diff=lfs merge=lfs -text
59
  data/PCA_REDUCED_dcase2023_task2_baseline_ae-embeddings_dev_test.npz filter=lfs diff=lfs merge=lfs -text
60
  data/PCA_REDUCED_dcase2023_task2_baseline_ae-embeddings_dev_train.npz filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  data/MIT_ast-finetuned-audioset-10-10-0-4593-embeddings_dev_test.npz filter=lfs diff=lfs merge=lfs -text
59
  data/PCA_REDUCED_dcase2023_task2_baseline_ae-embeddings_dev_test.npz filter=lfs diff=lfs merge=lfs -text
60
  data/PCA_REDUCED_dcase2023_task2_baseline_ae-embeddings_dev_train.npz filter=lfs diff=lfs merge=lfs -text
61
+ data/preview_dcase_2.png filter=lfs diff=lfs merge=lfs -text
62
+ data/preview_dcase.png filter=lfs diff=lfs merge=lfs -text
63
+ data/spotlight_save_layout.png filter=lfs diff=lfs merge=lfs -text
64
+ data/config-spotlight-layout.json filter=lfs diff=lfs merge=lfs -text
65
+ data/dcase2023_task2_baseline_ae-embeddings_dev_test.npz filter=lfs diff=lfs merge=lfs -text
66
+ data/dev_test.tar.gz.lock filter=lfs diff=lfs merge=lfs -text
67
+ data/dev_train.tar.gz filter=lfs diff=lfs merge=lfs -text
68
+ data/preview_dcase_1.png filter=lfs diff=lfs merge=lfs -text
69
+ data/dcase2023_task2_baseline_ae-embeddings_dev_train.npz filter=lfs diff=lfs merge=lfs -text
70
+ data/dev_test.tar.gz filter=lfs diff=lfs merge=lfs -text
71
+ data/dev_train.tar.gz.lock filter=lfs diff=lfs merge=lfs -text
72
+ data/MIT_ast-finetuned-audioset-10-10-0.4593-embeddings_add_train.npz filter=lfs diff=lfs merge=lfs -text
73
+ data/MIT_ast-finetuned-audioset-10-10-0.4593-embeddings_eval_test.npz filter=lfs diff=lfs merge=lfs -text
74
+ data/add_train.tar.gz filter=lfs diff=lfs merge=lfs -text
75
+ data/eval_test.tar.gz filter=lfs diff=lfs merge=lfs -text
7690148_urls.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ https://zenodo.org/record/7690148/files/dev_bearing.zip
2
+ https://zenodo.org/record/7690148/files/dev_fan.zip
3
+ https://zenodo.org/record/7690148/files/dev_gearbox.zip
4
+ https://zenodo.org/record/7690148/files/dev_slider.zip
5
+ https://zenodo.org/record/7690148/files/dev_ToyCar.zip
6
+ https://zenodo.org/record/7690148/files/dev_ToyTrain.zip
7
+ https://zenodo.org/record/7690148/files/dev_valve.zip
README.md CHANGED
@@ -160,10 +160,6 @@ a ClassLabel for the label and a ClassLabel for the class.
160
  'embeddings_dcase2023_task2_baseline_ae': [12.602639198303223,
161
  16.997364044189453, ...,
162
  -0.20931333303451538]
163
- 'anomaly_score_dcase2023_task2_baseline_ae': 8.284389
164
- 'prediction_dcase2023_task2_baseline_ae': 0
165
- 'prediction_correct_dcase2023_task2_baseline_ae': 1
166
- 'anomaly_score_embedding_lof': 0.191043
167
  }
168
  ```
169
 
@@ -183,11 +179,6 @@ The length of each audio file is 10 seconds.
183
  - `label`: an integer whose value may be either _0_, indicating that the audio sample is _normal_, _1_, indicating that the audio sample contains an _anomaly_.
184
  - `embeddings_ast-finetuned-audioset-10-10-0.4593`: an `datasets.Sequence(Value("float32"), shape=(1, 768))` representing audio embeddings that are generated with an [Audio Spectrogram Transformer](https://huggingface.co/docs/transformers/model_doc/audio-spectrogram-transformer#transformers.ASTFeatureExtractor).
185
  - `embeddings_dcase2023_task2_baseline_ae`: an `datasets.Sequence(Value("float32"), shape=(1, 512))` representing audio embeddings that are generated with the [**DCASE 2023 Challenge Task 2 Baseline Auto Encoder**](https://github.com/nttcslab/dcase2023_task2_baseline_ae). **Seven individual class-specific AEs** are trained. Dimensionality Reduction is applied with **PCA** separately for each class with a fit on the respecting training set of samples.
186
- - `anomaly_score_dcase2023_task2_baseline_ae`: a float representation of the anomaly score according to the baseline implementation
187
- - `prediction_dcase2023_task2_baseline_ae`: an integer whose value may be either _0_, indicating that the audio sample is considered _normal_ by the baseline algorithm, _1_, indicating that the audio sample contains an _anomaly_.
188
- - `prediction_correct_dcase2023_task2_baseline_ae`: an integer whose value may be either _0_, indicating that the baseline prediction is wrong or _1_, indicating that prediction is correct.
189
- - `anomaly_score_embedding_lof`: a float representation of the anomaly score computed with the PyOD implementation of the Local Outlier Factor algorithm on the pre-computed embedding.
190
-
191
 
192
  ### Data Splits
193
 
@@ -198,7 +189,18 @@ The development dataset has 2 splits: _train_ and _test_.
198
  | Train | 7000 | 6930 / 70 |
199
  | Test | 1400 | 700 / 700 |
200
 
201
- The information for the evaluation dataset will follow after release.
 
 
 
 
 
 
 
 
 
 
 
202
 
203
  ## Dataset Creation
204
 
@@ -300,22 +302,22 @@ If you use this dataset, please cite all the following papers. We will publish a
300
  - Noboru Harada, Daisuke Niizumi, Daiki Takeuchi, Yasunori Ohishi, and Masahiro Yasuda. First-shot anomaly detection for machine condition monitoring: a domain generalization baseline. In arXiv e-prints: 2303.00455, 2023. [[URL](https://arxiv.org/abs/2303.00455.pdf)]
301
 
302
  ```
303
- @dataset{kota_dohi_2023_7687464,
304
  author = {Kota Dohi and
305
- Keisuke and
306
- Noboru and
307
- Daisuke and
308
- Yuma and
309
- Tomoya and
310
- Harsh and
311
- Takashi and
312
- Yohei},
313
  title = {DCASE 2023 Challenge Task 2 Development Dataset},
314
  month = mar,
315
  year = 2023,
316
  publisher = {Zenodo},
317
- version = {1.0},
318
- doi = {10.5281/zenodo.7687464},
319
- url = {https://doi.org/10.5281/zenodo.7687464}
320
  }
321
  ```
 
160
  'embeddings_dcase2023_task2_baseline_ae': [12.602639198303223,
161
  16.997364044189453, ...,
162
  -0.20931333303451538]
 
 
 
 
163
  }
164
  ```
165
 
 
179
  - `label`: an integer whose value may be either _0_, indicating that the audio sample is _normal_, _1_, indicating that the audio sample contains an _anomaly_.
180
  - `embeddings_ast-finetuned-audioset-10-10-0.4593`: an `datasets.Sequence(Value("float32"), shape=(1, 768))` representing audio embeddings that are generated with an [Audio Spectrogram Transformer](https://huggingface.co/docs/transformers/model_doc/audio-spectrogram-transformer#transformers.ASTFeatureExtractor).
181
  - `embeddings_dcase2023_task2_baseline_ae`: an `datasets.Sequence(Value("float32"), shape=(1, 512))` representing audio embeddings that are generated with the [**DCASE 2023 Challenge Task 2 Baseline Auto Encoder**](https://github.com/nttcslab/dcase2023_task2_baseline_ae). **Seven individual class-specific AEs** are trained. Dimensionality Reduction is applied with **PCA** separately for each class with a fit on the respecting training set of samples.
 
 
 
 
 
182
 
183
  ### Data Splits
184
 
 
189
  | Train | 7000 | 6930 / 70 |
190
  | Test | 1400 | 700 / 700 |
191
 
192
+ The additional training dataset has 1 split: _train_.
193
+
194
+ | Dataset Split | Number of Instances in Split | Source Domain / Target Domain Samples |
195
+ | ------------- |------------------------------|---------------------------------------|
196
+ | Train | 7000 | 6930 / 70 |
197
+
198
+ The evaluation dataset has 1 split: _test_.
199
+
200
+ | Dataset Split | Number of Instances in Split | Source Domain / Target Domain Samples |
201
+ |---------------|------------------------------|---------------------------------------|
202
+ | Test | 1400 | ? |
203
+
204
 
205
  ## Dataset Creation
206
 
 
302
  - Noboru Harada, Daisuke Niizumi, Daiki Takeuchi, Yasunori Ohishi, and Masahiro Yasuda. First-shot anomaly detection for machine condition monitoring: a domain generalization baseline. In arXiv e-prints: 2303.00455, 2023. [[URL](https://arxiv.org/abs/2303.00455.pdf)]
303
 
304
  ```
305
+ @dataset{kota_dohi_2023_7882613,
306
  author = {Kota Dohi and
307
+ Keisuke Imoto and
308
+ Noboru Harada and
309
+ Daisuke Niizumi and
310
+ Yuma Koizumi and
311
+ Tomoya Nishida and
312
+ Harsh Purohit and
313
+ Takashi Endo and
314
+ Yohei Kawaguchi},
315
  title = {DCASE 2023 Challenge Task 2 Development Dataset},
316
  month = mar,
317
  year = 2023,
318
  publisher = {Zenodo},
319
+ version = {3.0},
320
+ doi = {10.5281/zenodo.7882613},
321
+ url = {https://doi.org/10.5281/zenodo.7882613}
322
  }
323
  ```
dcase23-task2-enriched.py CHANGED
@@ -13,23 +13,23 @@ from typing import Iterable, Dict, Optional, Union, List
13
 
14
 
15
  _CITATION = """\
16
- @dataset{kota_dohi_2023_7687464,
17
  author = {Kota Dohi and
18
- Keisuke and
19
- Noboru and
20
- Daisuke and
21
- Yuma and
22
- Tomoya and
23
- Harsh and
24
- Takashi and
25
- Yohei},
26
  title = {DCASE 2023 Challenge Task 2 Development Dataset},
27
  month = mar,
28
  year = 2023,
29
  publisher = {Zenodo},
30
- version = {1.0},
31
- doi = {10.5281/zenodo.7687464},
32
- url = {https://doi.org/10.5281/zenodo.7687464}
33
  }
34
  """
35
  _LICENSE = "Creative Commons Attribution 4.0 International Public License"
@@ -37,13 +37,13 @@ _LICENSE = "Creative Commons Attribution 4.0 International Public License"
37
  _METADATA_REG = r"attributes_\d+.csv"
38
 
39
  _NUM_TARGETS = 2
40
- _NUM_CLASSES = 7
41
 
42
  _TARGET_NAMES = ["normal", "anomaly"]
43
- _CLASS_NAMES = ["gearbox", "fan", "bearing", "slider", "ToyCar", "ToyTrain", "valve"]
44
 
45
  _HOMEPAGE = {
46
- "dev": "https://zenodo.org/record/7687464#.Y_96q9LMLmH",
47
  "add": "",
48
  "eval": "",
49
  }
@@ -52,24 +52,23 @@ DATA_URLS = {
52
  "dev": {
53
  "train": "data/dev_train.tar.gz",
54
  "test": "data/dev_test.tar.gz",
55
- "metadata": "data/dev_metadata_extended.csv",
56
  },
57
  "add": {
58
  "train": "data/add_train.tar.gz",
59
- "test": "data/add_test.tar.gz",
60
- "metadata": "data/add_metadata_extended.csv",
61
  },
62
  "eval": {
63
  "test": "data/eval_test.tar.gz",
64
- "metadata": "data/eval_metadata_extended.csv",
65
  },
66
  }
67
 
68
  EMBEDDING_URLS = {
69
  "dev": {
70
  "embeddings_ast-finetuned-audioset-10-10-0.4593": {
71
- "train": "data/MIT_ast-finetuned-audioset-10-10-0-4593-embeddings_dev_train.npz",
72
- "test": "data/MIT_ast-finetuned-audioset-10-10-0-4593-embeddings_dev_test.npz",
73
  "size": (1, 768),
74
  "dtype": "float32",
75
  },
@@ -83,22 +82,16 @@ EMBEDDING_URLS = {
83
  },
84
  "add": {
85
  "embeddings_ast-finetuned-audioset-10-10-0.4593": {
86
- "train": "",
87
- "test": "",
88
- },
89
- "embeddings_dcase2023_task2_baseline_ae": {
90
- "train": "",
91
- "test": "",
92
  },
93
  },
94
  "eval": {
95
  "embeddings_ast-finetuned-audioset-10-10-0.4593": {
96
- "train": "",
97
- "test": "",
98
- },
99
- "embeddings_dcase2023_task2_baseline_ae": {
100
- "train": "",
101
- "test": "",
102
  },
103
  },
104
  }
@@ -108,22 +101,22 @@ STATS = {
108
  "configs": {
109
  'dev': {
110
  'date': "Mar 1, 2023",
111
- 'version': "1.0.0",
112
- 'homepage': "https://zenodo.org/record/7687464#.ZABmANLMLmH",
113
  "splits": ["train", "test"],
114
  },
115
- # 'add': {
116
- # 'date': None,
117
- # 'version': "0.0.0",
118
- # 'homepage': None,
119
- # "splits": ["train", "test"],
120
- # },
121
- # 'eval': {
122
- # 'date': None,
123
- # 'version': "0.0.0",
124
- # 'homepage': None,
125
- # "splits": ["test"],
126
- # },
127
  }
128
  }
129
 
@@ -381,10 +374,6 @@ class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
381
  "d2v": datasets.Value("string"),
382
  "d3p": datasets.Value("string"),
383
  "d3v": datasets.Value("string"),
384
- "anomaly_score_dcase2023_task2_baseline_ae": datasets.Value("float32"),
385
- "prediction_dcase2023_task2_baseline_ae": datasets.Value("int64"),
386
- "prediction_correct_dcase2023_task2_baseline_ae": datasets.Value("int64"),
387
- "anomaly_score_embedding_lof": datasets.Value("float32"),
388
  }
389
  if self.config.embeddings_urls is not None:
390
  features.update({
@@ -436,7 +425,7 @@ class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
436
  "local_extracted_archive": local_extracted_archive[split],
437
  "audio_files": dl_manager.iter_archive(audio_path[split]),
438
  "embeddings": embeddings[split],
439
- "metadata_file": dl_manager.download_and_extract(self.config.data_urls["metadata"]),
440
  "is_streaming": dl_manager.is_streaming,
441
  },
442
  ) for split in split_type if split in self.config.splits
@@ -452,20 +441,22 @@ class DCASE2023Task2Dataset(datasets.GeneratorBasedBuilder):
452
  is_streaming: Optional[bool],
453
  ):
454
  """Yields examples."""
455
- metadata = pd.read_csv(metadata_file)
 
456
  data_fields = list(self._info().features.keys())
457
 
458
  id_ = 0
459
  for path, f in audio_files:
460
  lookup = Path(path).parent.name + "/" + Path(path).name
461
- if lookup in metadata["path"].values:
462
  path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
463
  if is_streaming:
464
  audio = {"path": path, "bytes": f.read()}
465
  else:
466
  audio = {"path": path, "bytes": None}
467
  result = {field: None for field in data_fields}
468
- result.update(metadata[metadata["path"] == lookup].T.squeeze().to_dict())
 
469
  for emb_key in embeddings.keys():
470
  result[emb_key] = np.asarray(embeddings[emb_key][lookup]).squeeze().tolist()
471
  result["path"] = path
 
13
 
14
 
15
  _CITATION = """\
16
+ @dataset{kota_dohi_2023_7882613,
17
  author = {Kota Dohi and
18
+ Keisuke Imoto and
19
+ Noboru Harada and
20
+ Daisuke Niizumi and
21
+ Yuma Koizumi and
22
+ Tomoya Nishida and
23
+ Harsh Purohit and
24
+ Takashi Endo and
25
+ Yohei Kawaguchi},
26
  title = {DCASE 2023 Challenge Task 2 Development Dataset},
27
  month = mar,
28
  year = 2023,
29
  publisher = {Zenodo},
30
+ version = {3.0},
31
+ doi = {10.5281/zenodo.7882613},
32
+ url = {https://doi.org/10.5281/zenodo.7882613}
33
  }
34
  """
35
  _LICENSE = "Creative Commons Attribution 4.0 International Public License"
 
37
  _METADATA_REG = r"attributes_\d+.csv"
38
 
39
  _NUM_TARGETS = 2
40
+ _NUM_CLASSES = 14
41
 
42
  _TARGET_NAMES = ["normal", "anomaly"]
43
+ _CLASS_NAMES = ["gearbox", "fan", "bearing", "slider", "ToyCar", "ToyTrain", "valve", "bandsaw", "grinder", "shaker", "ToyDrone", "ToyNscale", "ToyTank", "Vacuum"]
44
 
45
  _HOMEPAGE = {
46
+ "dev": "https://zenodo.org/record/7690157",
47
  "add": "",
48
  "eval": "",
49
  }
 
52
  "dev": {
53
  "train": "data/dev_train.tar.gz",
54
  "test": "data/dev_test.tar.gz",
55
+ "metadata": "data/dev_metadata.csv",
56
  },
57
  "add": {
58
  "train": "data/add_train.tar.gz",
59
+ "metadata": "data/add_metadata.csv",
 
60
  },
61
  "eval": {
62
  "test": "data/eval_test.tar.gz",
63
+ "metadata": None,
64
  },
65
  }
66
 
67
  EMBEDDING_URLS = {
68
  "dev": {
69
  "embeddings_ast-finetuned-audioset-10-10-0.4593": {
70
+ "train": "data/MIT_ast-finetuned-audioset-10-10-0.4593-embeddings_dev_train.npz",
71
+ "test": "data/MIT_ast-finetuned-audioset-10-10-0.4593-embeddings_dev_test.npz",
72
  "size": (1, 768),
73
  "dtype": "float32",
74
  },
 
82
  },
83
  "add": {
84
  "embeddings_ast-finetuned-audioset-10-10-0.4593": {
85
+ "train": "data/MIT_ast-finetuned-audioset-10-10-0.4593-embeddings_add_train.npz",
86
+ "size": (1, 768),
87
+ "dtype": "float32",
 
 
 
88
  },
89
  },
90
  "eval": {
91
  "embeddings_ast-finetuned-audioset-10-10-0.4593": {
92
+ "test": "data/MIT_ast-finetuned-audioset-10-10-0.4593-embeddings_eval_test.npz",
93
+ "size": (1, 768),
94
+ "dtype": "float32",
 
 
 
95
  },
96
  },
97
  }
 
101
  "configs": {
102
  'dev': {
103
  'date': "Mar 1, 2023",
104
+ 'version': "3.0.0",
105
+ 'homepage': "https://zenodo.org/record/7882613",
106
  "splits": ["train", "test"],
107
  },
108
+ 'add': {
109
+ 'date': "Apr 15, 2023",
110
+ 'version': "1.0.0",
111
+ 'homepage': "https://zenodo.org/record/7830345",
112
+ "splits": ["train"],
113
+ },
114
+ 'eval': {
115
+ 'date': "May 1, 2023",
116
+ 'version': "1.0.0",
117
+ 'homepage': "https://zenodo.org/record/7860847",
118
+ "splits": ["test"],
119
+ },
120
  }
121
  }
122
 
 
374
  "d2v": datasets.Value("string"),
375
  "d3p": datasets.Value("string"),
376
  "d3v": datasets.Value("string"),
 
 
 
 
377
  }
378
  if self.config.embeddings_urls is not None:
379
  features.update({
 
425
  "local_extracted_archive": local_extracted_archive[split],
426
  "audio_files": dl_manager.iter_archive(audio_path[split]),
427
  "embeddings": embeddings[split],
428
+ "metadata_file": dl_manager.download_and_extract(self.config.data_urls["metadata"]) if self.config.data_urls["metadata"] is not None else None,
429
  "is_streaming": dl_manager.is_streaming,
430
  },
431
  ) for split in split_type if split in self.config.splits
 
441
  is_streaming: Optional[bool],
442
  ):
443
  """Yields examples."""
444
+ if metadata_file is not None:
445
+ metadata = pd.read_csv(metadata_file)
446
  data_fields = list(self._info().features.keys())
447
 
448
  id_ = 0
449
  for path, f in audio_files:
450
  lookup = Path(path).parent.name + "/" + Path(path).name
451
+ if metadata_file is None or lookup in metadata["path"].values:
452
  path = os.path.join(local_extracted_archive, path) if local_extracted_archive else path
453
  if is_streaming:
454
  audio = {"path": path, "bytes": f.read()}
455
  else:
456
  audio = {"path": path, "bytes": None}
457
  result = {field: None for field in data_fields}
458
+ if metadata_file is not None:
459
+ result.update(metadata[metadata["path"] == lookup].T.squeeze().to_dict())
460
  for emb_key in embeddings.keys():
461
  result[emb_key] = np.asarray(embeddings[emb_key][lookup]).squeeze().tolist()
462
  result["path"] = path