Downloading the dataset locally
#27
by
basitt-7
- opened
Hello, does this script download the objects locally on the system? If yes, where can I find it?
objects = objaverse.load_objects(
uids=object_uids,
download_processes=processes
)
From the source code:
def load_objects(uids: List[str], download_processes: int = 1) -> Dict[str, str]:
"""Return the path to the object files for the given uids.
If the object is not already downloaded, it will be downloaded.
Args:
uids: A list of uids.
download_processes: The number of processes to use to download the objects.
Returns:
A dictionary mapping the object uid to the local path of where the object
downloaded.
"""
object_paths = _load_object_paths()
out = {}
if download_processes == 1:
uids_to_download = []
for uid in uids:
if uid.endswith(".glb"):
uid = uid[:-4]
if uid not in object_paths:
warnings.warn(f"Could not find object with uid {uid}. Skipping it.")
continue
object_path = object_paths[uid]
local_path = os.path.join(_VERSIONED_PATH, object_path)
if os.path.exists(local_path):
out[uid] = local_path
continue
uids_to_download.append((uid, object_path))
if len(uids_to_download) == 0:
return out
start_file_count = len(
glob.glob(os.path.join(_VERSIONED_PATH, "glbs", "*", "*.glb"))
)
for uid, object_path in uids_to_download:
uid, local_path = _download_object(
uid, object_path, len(uids_to_download), start_file_count
)
out[uid] = local_path
else:
args = []
for uid in uids:
if uid.endswith(".glb"):
uid = uid[:-4]
if uid not in object_paths:
warnings.warn(f"Could not find object with uid {uid}. Skipping it.")
continue
object_path = object_paths[uid]
local_path = os.path.join(_VERSIONED_PATH, object_path)
if not os.path.exists(local_path):
args.append((uid, object_paths[uid]))
else:
out[uid] = local_path
if len(args) == 0:
return out
print(
f"starting download of {len(args)} objects with {download_processes} processes"
)
start_file_count = len(
glob.glob(os.path.join(_VERSIONED_PATH, "glbs", "*", "*.glb"))
)
args = [(*arg, len(args), start_file_count) for arg in args]
with multiprocessing.Pool(download_processes) as pool:
r = pool.starmap(_download_object, args)
for uid, local_path in r:
out[uid] = local_path
return out