|
import pandas as pd |
|
import os |
|
import fsspec |
|
import requests |
|
|
|
|
|
def load_github_metadata(download_dir: str = "~/.objaverse") -> pd.DataFrame: |
|
"""Loads the GitHub 3D object metadata as a Pandas DataFrame. |
|
|
|
Args: |
|
download_dir (str, optional): Directory to download the parquet metadata file. |
|
Supports all file systems supported by fsspec. Defaults to "~/.objaverse". |
|
|
|
Returns: |
|
pd.DataFrame: GitHub 3D object metadata as a Pandas DataFrame with columns for |
|
the object "githubUrl", "license", and "sha256". |
|
""" |
|
filename = os.path.join(download_dir, "github", "github-urls.parquet") |
|
fs, path = fsspec.core.url_to_fs(filename) |
|
fs.makedirs(os.path.dirname(path), exist_ok=True) |
|
|
|
|
|
if not fs.exists(path): |
|
url = "https://huggingface.co/datasets/allenai/objaverse-xl/resolve/main/github/github-urls.parquet" |
|
|
|
response = requests.get(url) |
|
response.raise_for_status() |
|
with fs.open(path, "wb") as file: |
|
file.write(response.content) |
|
|
|
|
|
with fs.open(path) as f: |
|
df = pd.read_parquet(f) |
|
|
|
return df |
|
|