Skip to content

Instantly share code, notes, and snippets.

@miguelmartin75
Last active December 16, 2023 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmartin75/b2bfeec06e51ce217ab2613761d9cd7b to your computer and use it in GitHub Desktop.
Save miguelmartin75/b2bfeec06e51ce217ab2613761d9cd7b to your computer and use it in GitHub Desktop.
Use this if you have files in `<download_dir>/captures/captures` or `<download_dir>/takes/takes`. Please also redownload with the CLI with the flag `-d`. Apologies for the inconvenience.
import os
import sys
import shutil
from tqdm.auto import tqdm
assert len(sys.argv) > 1, "Please provide the dataset_dir"
dataset_dir = sys.argv[1]
assert os.path.exists(dataset_dir), f"{dataset_dir} does not exist"
assert os.path.exists(os.path.join(dataset_dir, "takes")), f"Wrong folder provided, given: {dataset_dir}"
takes = os.path.join(dataset_dir, "takes/takes")
take_dirs = os.listdir(takes) if os.path.exists(takes) else []
captures = os.path.join(dataset_dir, "captures/captures")
capture_dirs = os.listdir(captures) if os.path.exists(captures) else []
for td in tqdm(capture_dirs):
src = os.path.join(dataset_dir, "captures/captures/", td)
if not os.path.exists(src):
continue
dst = os.path.join(dataset_dir, "captures")
shutil.rmtree(os.path.join(dst, td), ignore_errors=True)
shutil.move(src, dst)
for td in tqdm(take_dirs):
src = os.path.join(dataset_dir, "takes/takes/", td)
if not os.path.exists(src):
continue
dst = os.path.join(dataset_dir, "takes")
shutil.rmtree(os.path.join(dst, td), ignore_errors=True)
shutil.move(src, dst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment