INNER CODE UNIT · Python
_load_object_paths
allenai/objaverse-xl · objaverse/__init__.py:58
def _load_object_paths() -> Dict[str, str]:
"""Load the object paths from the dataset.
The object paths specify the location of where the object is located
in the Hugging Face repo.
Returns:
A dictionary mapping the uid to the object path.
"""
object_paths_file = "object-paths.json.gz"
local_path = os.path.join(_VERSIONED_PATH, object_paths_file)
if not os.path.exists(local_path):
hf_url = f"https://huggingface.co/datasets/allenai/objaverse/resolve/main/{object_paths_file}"
# wget the file and put it in local_path
os.makedirs(os.path.dirname(local_path), exist_ok=True)
urllib.request.urlretrieve(hf_url, local_path)
with gzip.open(local_path, "rb") as f:
object_paths = json.load(f)