Skip to content

Commit

Permalink
Ego-Exo4D minor CLI downloader fixes (#321)
Browse files Browse the repository at this point in the history
Summary:
- Errors on invalid benchmark names
- Improve delete confirmation prompt

Manifest generation:
- Adds egopose's camera_pose test set files to be downloaded

Pull Request resolved: #321

Reviewed By: suyogduttjain

Differential Revision: D55777584

Pulled By: miguelmartin75

fbshipit-source-id: 5e9c404bb38d9cc29d83c2bb44070e659b31923d
  • Loading branch information
Miguel Martin authored and facebook-github-bot committed Apr 9, 2024
1 parent 663b000 commit 6056f8d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
61 changes: 38 additions & 23 deletions ego4d/internal/download/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@ def download(
continue

ms = manifest_loads(pathmgr.open(manifest_path).read())
valid_benchmark_names = {b for m in ms for b in m.benchmarks or []}
invalid_benchmarks = (
args.benchmarks - valid_benchmark_names if args.benchmarks else set()
)
if len(invalid_benchmarks) > 0:
print(f"Provided invalid benchmarks: {invalid_benchmarks}")
print("Valid benchmark names include: ")
print()
for b in valid_benchmark_names:
print(b)
print()
print("Quitting ...")
sys.exit(3)

for m in ms:
num_paths += len(m.paths)
if not _manifest_ok(m, args):
Expand Down Expand Up @@ -348,7 +362,7 @@ def download(
ps_to_dl = {
path: size
for path, size in path_size_pairs
if (path, size) not in existing_paths
if (path, size) not in existing_paths and size > 0
}
if len(ps_to_dl) == 0 and not args.force:
print("Everything has been downloaded. Bye.")
Expand Down Expand Up @@ -378,13 +392,6 @@ def download(
print("Aborting...")
sys.exit(0)

print("Preparing output directories ...")
all_out_dirs = {
os.path.join(out_dir, os.path.dirname(x.relative_path)) for x in all_paths
}
for x in tqdm(all_out_dirs):
os.makedirs(x, exist_ok=True)

if args.delete:
print("Scanning for files to delete ...")
files_that_exist = []
Expand All @@ -395,24 +402,32 @@ def download(
files_to_delete = files_that_exist - {
os.path.join(out_dir, x[0].relative_path) for x in path_size_pairs
}
response = input(
f"Will delete: {len(files_to_delete)} files (there is {len(files_that_exist)} total files) "
f"Continue? (y/[n]): "
)
if not delete_yes:
if response.lower() in ["yes", "y"]:
confirm = True
if len(files_to_delete) > 0:
response = input(
f"Will delete: {len(files_to_delete)} files (there is {len(files_that_exist)} total files) "
f"Continue? (y/[n]): "
)
if not delete_yes:
if response.lower() in ["yes", "y"]:
confirm = True
else:
confirm = False
else:
confirm = False
else:
confirm = True
confirm = True

if not confirm:
print("Aborting...")
sys.exit(0)

if not confirm:
print("Aborting...")
sys.exit(0)
for f in tqdm(files_to_delete):
os.remove(f)

for f in tqdm(files_to_delete):
os.remove(f)
print("Preparing output directories ...")
all_out_dirs = {
os.path.join(out_dir, os.path.dirname(x.relative_path)) for x in all_paths
}
for x in tqdm(all_out_dirs):
os.makedirs(x, exist_ok=True)

print("Downloading ...")
assert all(size is not None for size in ps_to_dl.values())
Expand Down
5 changes: 4 additions & 1 deletion ego4d/internal/download/manifest_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,11 @@ def map_take(t):
}
if not dev_release:
egopose_base_dir = os.path.join(release_dir, "annotations/ego_pose/")
for split in ["train", "val"]:
for split in ["train", "val", "test"]:
for part in ["body", "hand", "camera_pose"]:
if part in ("body", "hand") and split == "test":
continue

subdir = os.path.join(egopose_base_dir, split, part)
print(subdir)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="ego4d",
version="1.7.1",
version="1.7.2",
author="FAIR",
author_email="info@ego4d-data.org",
description="Ego4D Dataset CLI",
Expand Down

0 comments on commit 6056f8d

Please sign in to comment.