ProgramComputer commited on
Commit
1be08e5
·
1 Parent(s): 1265dc9

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +41 -45
test.py CHANGED
@@ -273,14 +273,10 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
273
  for placeholder_key in ("dev", "test")
274
  ))
275
 
276
- #mapped_paths["test"] = {k:tuple(dl_manager.iter_files(e) for e in v) for k, v in mapped_paths["test"].items()}
277
- #mapped_paths["dev"] = {k:tuple(dl_manager.iter_files(e) for e in v) for k, v in mapped_paths["dev"].items()}
278
- #mapped_paths["test"] = {k: tuple(f for f in dl_manager.iter_files(v) ) for k, v in mapped_paths["test"].items()}
279
- #mapped_paths["dev"] = {k: tuple(f for value in v.values() for f in dl_manager.iter_files(value) ) for k, v in mapped_paths["dev"].items()}
280
  apply_function_recursive = lambda d, f: {k: apply_function_recursive(v, f) if isinstance(v, dict) else f(v) for k, v in d.items()}
281
 
282
  mapped_paths = apply_function_recursive(mapped_paths, dl_manager.iter_files)
283
- raise Exception(mapped_paths)
284
  return [
285
  datasets.SplitGenerator(
286
  name="train",
@@ -312,43 +308,43 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
312
  )
313
 
314
  for path in paths[conf]:
315
- raise Exception([x for x in Path(path).glob('**/*')])
316
- # def find_mount_point(path):
317
- # path = os.path.realpath(path)
318
- # while not os.path.ismount(path):
319
- # path = os.path.dirname(path)
320
- # return path
321
- # raise Exception(find_mount_point(path))
322
- #subdirs = [x[0] for x in os.walk(path)]
323
- #raise Exception(subdirs)
324
- #raise Exception(path)
325
- # #raise Exception(os.is_symlink(path))
326
- # #raise Exception(os.listdir(path))
327
- # try:
328
- # t = tuple(path.split("::")[0].split("/")[2:])
329
- # _,dataset_format,speaker,video_id,clip_index= (None,) * (5 - len(t)) + t
330
- # except Exception:
331
- # raise Exception(file.split("::")[0].split("/")[2:])
332
- # speaker_info = meta.loc[speaker]
333
- # clip_index = int(Path(clip_index).stem)
334
- # info = {
335
- # "file": path,
336
- # "file_format": dataset_format,
337
- # "dataset_id": dataset_id,
338
- # "speaker_id": speaker,
339
- # "speaker_gender": speaker_info["Gender"],
340
- # "video_id": video_id,
341
- # "clip_index": clip_index,
342
- # }
343
- # if dataset_id == "vox1":
344
- # info["speaker_name"] = speaker_info["VGGFace1 ID"]
345
- # info["speaker_nationality"] = speaker_info["Nationality"]
346
- # if conf.startswith("audio"):
347
- # info["audio"] = info["file"]
348
- # if conf.startswith("video"):
349
- # with fs.open(info["file"], 'rb') as f:
350
- # #buffer = BytesIO()
351
- # #f.write(buffer)
352
- # info["video"] = BytesIO(f.read()).getvalue()
353
- # yield key, info
354
- # key += 1
 
273
  for placeholder_key in ("dev", "test")
274
  ))
275
 
276
+
 
 
 
277
  apply_function_recursive = lambda d, f: {k: apply_function_recursive(v, f) if isinstance(v, dict) else f(v) for k, v in d.items()}
278
 
279
  mapped_paths = apply_function_recursive(mapped_paths, dl_manager.iter_files)
 
280
  return [
281
  datasets.SplitGenerator(
282
  name="train",
 
308
  )
309
 
310
  for path in paths[conf]:
311
+ for file in path:
312
+ def find_mount_point(path):
313
+ path = os.path.realpath(path)
314
+ while not os.path.ismount(path):
315
+ path = os.path.dirname(path)
316
+ return path
317
+ raise Exception(find_mount_point(path))
318
+ subdirs = [x[0] for x in os.walk(path)]
319
+ raise Exception(subdirs)
320
+ raise Exception(path)
321
+ #raise Exception(os.is_symlink(path))
322
+ #raise Exception(os.listdir(path))
323
+ try:
324
+ t = tuple(file.split("::")[0].split("/")[2:])
325
+ _,dataset_format,speaker,video_id,clip_index= (None,) * (5 - len(t)) + t
326
+ except Exception:
327
+ raise Exception(file.split("::")[0].split("/")[2:])
328
+ speaker_info = meta.loc[speaker]
329
+ clip_index = int(Path(clip_index).stem)
330
+ info = {
331
+ "file": file,
332
+ "file_format": dataset_format,
333
+ "dataset_id": dataset_id,
334
+ "speaker_id": speaker,
335
+ "speaker_gender": speaker_info["Gender"],
336
+ "video_id": video_id,
337
+ "clip_index": clip_index,
338
+ }
339
+ if dataset_id == "vox1":
340
+ info["speaker_name"] = speaker_info["VGGFace1 ID"]
341
+ info["speaker_nationality"] = speaker_info["Nationality"]
342
+ if conf.startswith("audio"):
343
+ info["audio"] = info["file"]
344
+ if conf.startswith("video"):
345
+ with fs.open(info["file"], 'rb') as f:
346
+ #buffer = BytesIO()
347
+ #f.write(buffer)
348
+ info["video"] = BytesIO(f.read()).getvalue()
349
+ yield key, info
350
+ key += 1