Commit
·
1be08e5
1
Parent(s):
1265dc9
Update test.py
Browse files
test.py
CHANGED
@@ -273,14 +273,10 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
|
|
273 |
for placeholder_key in ("dev", "test")
|
274 |
))
|
275 |
|
276 |
-
|
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 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
|
|
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
|