ProgramComputer commited on
Commit
ab17375
1 Parent(s): d75eab0

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +49 -100
test.py CHANGED
@@ -24,16 +24,13 @@ from itertools import repeat
24
  from multiprocessing import Manager, Pool, Process
25
  from pathlib import Path
26
  from shutil import copyfileobj
27
- import numpy as np
28
  import pandas as pd
29
  import requests
30
- from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, TypeVar, Union
31
- import warnings
32
  import datasets
33
  import urllib3
34
 
35
-
36
-
37
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
38
 
39
  _CITATION = """\
@@ -68,41 +65,41 @@ _URL = "https://mm.kaist.ac.kr/datasets/voxceleb"
68
 
69
  _URLS = {
70
  "video": {
71
- "placeholder": "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partaa",
72
  "dev": (
73
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partaa",
74
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partab",
75
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partac",
76
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partad",
77
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partae",
78
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partaf",
79
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partag",
80
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partah",
81
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_mp4_partai",
82
  ),
83
  "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_test_mp4.zip",
84
  },
85
  "audio1": {
86
- "placeholder": "hf://datasets/ProgramComputer/voxceleb/vox1/vox1_dev_wav_partaa",
87
  "dev": (
88
- "hf://datasets/ProgramComputer/voxceleb/vox1/vox1_dev_wav_partaa",
89
- "hf://datasets/ProgramComputer/voxceleb/vox1/vox1_dev_wav_partab",
90
- "hf://datasets/ProgramComputer/voxceleb/vox1/vox1_dev_wav_partac",
91
- "hf://datasets/ProgramComputer/voxceleb/vox1/vox1_dev_wav_partad",
92
  ),
93
  "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_test_wav.zip",
94
  },
95
  "audio2": {
96
- "placeholder": "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partaa",
97
  "dev": (
98
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partaa",
99
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partab",
100
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partac",
101
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partad",
102
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partae",
103
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partaf",
104
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partag",
105
- "hf://datasets/ProgramComputer/voxceleb/vox2/vox2_dev_aac_partah",
106
  ),
107
  "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_test_aac.zip",
108
  },
@@ -115,20 +112,8 @@ _PLACEHOLDER_MAPS = dict(
115
  for urls in _URLS.values()
116
  for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
117
  )
118
- class NestedDataStructure:
119
- def __init__(self, data=None):
120
- self.data = data if data is not None else []
121
 
122
- def flatten(self, data=None):
123
- data = data if data is not None else self.data
124
- if isinstance(data, dict):
125
- return self.flatten(list(data.values()))
126
- elif isinstance(data, (list, tuple)):
127
- return [flattened for item in data for flattened in self.flatten(item)]
128
- else:
129
- return [data]
130
 
131
-
132
  def _mp_download(
133
  url,
134
  tmp_path,
@@ -153,7 +138,7 @@ def _mp_download(
153
  raise ConnectionError("failed to fetch dataset")
154
 
155
 
156
- class Test(datasets.GeneratorBasedBuilder):
157
  """VoxCeleb is an unlabled dataset consisting of short clips of human speech from interviews on YouTube"""
158
 
159
  VERSION = datasets.Version("1.0.0")
@@ -202,11 +187,13 @@ class Test(datasets.GeneratorBasedBuilder):
202
  )
203
 
204
  def _split_generators(self, dl_manager):
 
 
205
  targets = (
206
  ["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
207
  )
208
-
209
-
210
  def download_custom(placeholder_url, path):
211
  nonlocal dl_manager
212
  sources = _PLACEHOLDER_MAPS[placeholder_url]
@@ -285,62 +272,31 @@ class Test(datasets.GeneratorBasedBuilder):
285
  for target in targets
286
  )
287
  )
288
- # tmp_paths = dl_manager.download(
289
- # dict( (
290
- # placeholder_key,
291
- # dict(
292
- # (target, _URLS[target][placeholder_key])
293
- # for target in targets
294
- # ),
295
- # )
296
- # for placeholder_key in ("dev",)
297
- # )
298
- # )
299
- # raise Exception("HELLO BEFORE")
300
- # mapped_paths = {"dev":{}}
301
- # for key,value in tmp_paths["dev"].items():
302
- # with open(value[0], "wb") as out:
303
- # mapped_paths['dev'][key] = (value[0])
304
- # for tmp_path in value[1:]:
305
- # with open(tmp_path, "rb") as tmp:
306
- # copyfileobj(tmp, out)
307
- # #tmp_path.unlink()
308
- # raise Exception("HELLO")
309
- mapped_paths = dl_manager.download_and_extract(
310
- dict( (
311
  placeholder_key,
312
  dict(
313
  (target, _URLS[target][placeholder_key])
314
  for target in targets
315
  ),
316
- )
317
- for placeholder_key in ("test",)
318
- )
319
- )
 
 
320
 
321
- #raise Exception(mapped_paths)
322
-
323
- # tmp_paths = dl_manager.extract_and_download(
324
-
325
- # dict(
326
- # (
327
- # placeholder_key,
328
- # dict(
329
- # (target, _URLS[target][placeholder_key])
330
- # for target in targets
331
- # ),
332
- # )
333
- # for placeholder_key in ("placeholder")
334
- # ))
335
- # with open(tmp_paths[0], "wb") as out:
336
- # for tmp_path in tmp_paths[1:]:
337
- # with open(tmp_path, "rb") as tmp:
338
- # copyfileobj(tmp, out)
339
- # tmp_path.unlink()
340
- # mapped_paths = mapped_paths.append(tmp_paths[0])
341
- # print(mapped_paths)
342
-
343
  return [
 
 
 
 
 
 
 
344
  datasets.SplitGenerator(
345
  name="test",
346
  gen_kwargs={
@@ -348,13 +304,6 @@ class Test(datasets.GeneratorBasedBuilder):
348
  "meta_paths": metadata,
349
  },
350
  ),
351
- # datasets.SplitGenerator(
352
- # name="dev",
353
- # gen_kwargs={
354
- # "paths": mapped_paths["dev"],
355
- # "meta_paths": metadata,
356
- # },
357
- # ),
358
  ]
359
 
360
  def _generate_examples(self, paths, meta_paths):
 
24
  from multiprocessing import Manager, Pool, Process
25
  from pathlib import Path
26
  from shutil import copyfileobj
27
+
28
  import pandas as pd
29
  import requests
30
+
 
31
  import datasets
32
  import urllib3
33
 
 
 
34
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
35
 
36
  _CITATION = """\
 
65
 
66
  _URLS = {
67
  "video": {
68
+ "placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_parta",
69
  "dev": (
70
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partaa",
71
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partab",
72
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partac",
73
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partad",
74
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partae",
75
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partaf",
76
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partag",
77
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partah",
78
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_mp4_partai",
79
  ),
80
  "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_test_mp4.zip",
81
  },
82
  "audio1": {
83
+ "placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_parta",
84
  "dev": (
85
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partaa",
86
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partab",
87
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partac",
88
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_dev_wav_partad",
89
  ),
90
  "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox1/vox1_test_wav.zip",
91
  },
92
  "audio2": {
93
+ "placeholder": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_parta",
94
  "dev": (
95
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partaa",
96
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partab",
97
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partac",
98
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partad",
99
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partae",
100
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partaf",
101
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partag",
102
+ "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_dev_aac_partah",
103
  ),
104
  "test": "https://huggingface.co/datasets/ProgramComputer/voxceleb/resolve/main/vox2/vox2_test_aac.zip",
105
  },
 
112
  for urls in _URLS.values()
113
  for value in ((urls["placeholder"], urls["dev"]), (urls["test"], (urls["test"],)))
114
  )
 
 
 
115
 
 
 
 
 
 
 
 
 
116
 
 
117
  def _mp_download(
118
  url,
119
  tmp_path,
 
138
  raise ConnectionError("failed to fetch dataset")
139
 
140
 
141
+ class VoxCeleb(datasets.GeneratorBasedBuilder):
142
  """VoxCeleb is an unlabled dataset consisting of short clips of human speech from interviews on YouTube"""
143
 
144
  VERSION = datasets.Version("1.0.0")
 
187
  )
188
 
189
  def _split_generators(self, dl_manager):
190
+ if dl_manager.is_streaming:
191
+ raise TypeError("Streaming is not supported for VoxCeleb")
192
  targets = (
193
  ["audio1", "audio2"] if self.config.name == "audio" else [self.config.name]
194
  )
195
+
196
+
197
  def download_custom(placeholder_url, path):
198
  nonlocal dl_manager
199
  sources = _PLACEHOLDER_MAPS[placeholder_url]
 
272
  for target in targets
273
  )
274
  )
275
+
276
+ mapped_paths = dl_manager.extract(
277
+ dl_manager.download_custom(
278
+ dict(
279
+ (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  placeholder_key,
281
  dict(
282
  (target, _URLS[target][placeholder_key])
283
  for target in targets
284
  ),
285
+ )
286
+ for placeholder_key in ("placeholder", "test")
287
+ ),
288
+ download_custom,
289
+ )
290
+ )
291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  return [
293
+ datasets.SplitGenerator(
294
+ name="train",
295
+ gen_kwargs={
296
+ "paths": mapped_paths["placeholder"],
297
+ "meta_paths": metadata,
298
+ },
299
+ ),
300
  datasets.SplitGenerator(
301
  name="test",
302
  gen_kwargs={
 
304
  "meta_paths": metadata,
305
  },
306
  ),
 
 
 
 
 
 
 
307
  ]
308
 
309
  def _generate_examples(self, paths, meta_paths):