-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_wandb_dataset.py
53 lines (41 loc) · 1.38 KB
/
create_wandb_dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import argparse
import os
import wandb
def main(dataset_dir, wandb_name, filter_files=True):
def keep(f):
if filter_files:
return ".tfrecord" in f or f.endswith(".md") or f.endswith(".sh")
else:
return True
files = [f for f in os.listdir(dataset_dir) if keep(f)]
assert files, f"No .tfrecord files found in {dataset_dir}"
run = wandb.init(
project="neural-audio-synthesis-thesis",
entity="neural-audio-synthesis-thesis",
name=f"dataset-{wandb_name}",
# sync_tensorboard=True,
config={
"dataset_dir": dataset_dir,
"wandb_name": wandb_name,
},
tags=["dataset"],
)
metadata = dict(
example_secs=4,
sample_rate=16000,
frame_rate=50,
centered=True,
with_jukebox=True,
)
artifact = wandb.Artifact(wandb_name, type="dataset", metadata=metadata)
for f in files:
artifact.add_file(os.path.join(dataset_dir, f))
run.log_artifact(artifact)
print("Done.")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("dataset_dir")
parser.add_argument("--wandb-name", required=True)
parser.add_argument("--all-files", action="store_true", dest="all_files")
args = parser.parse_args()
main(args.dataset_dir, args.wandb_name, filter_files=not args.all_files)