as addition to Untar_data requires .tgz file ending
and COCO dataset is a .zip
file. May be better implement more general solution? Something like:
def unzip(fname: Path, dest: Optional[PathOrStr] = None):
dest = fname.parent if dest is None else dest
with zipfile.ZipFile(fname) as f:
f.extractall(dest)
def untar(fname: Path, dest: Optional[PathOrStr] = None):
dest = fname.parent if dest is None else dest
tarfile.open(fname, "r:gz").extractall(dest)
UNPACKERS = {".zip": unzip, ".tar": untar, ".tar.gz": untar}
def unpack(url: str, fname: PathOrStr = None):
fname = Config.data_path()/(fname or url.split("/")[-1])
suffix = "".join(fname.suffixes)
if not fname.exists():
download_data(url, fname)
UNPACKERS[suffix](fname)
return fname