mattdeitke
commited on
Commit
·
24cab06
1
Parent(s):
865bb18
add load_smithsonian_df
Browse files- objaverse_xl/__init__.py +28 -2
objaverse_xl/__init__.py
CHANGED
@@ -1,5 +1,31 @@
|
|
|
|
|
|
1 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
pass
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import pandas as pd
|
4 |
+
import requests
|
5 |
+
|
6 |
+
|
7 |
+
def load_smithsonian_df(
|
8 |
+
download_dir: str = "~/.objaverse_xl",
|
9 |
+
) -> pd.DataFrame:
|
10 |
+
"""Loads the Smithsonian Object Metadata dataset as a Pandas DataFrame.
|
11 |
+
|
12 |
+
Args:
|
13 |
+
download_dir (str, optional): Directory to download the parquet metadata file.
|
14 |
+
Defaults to "~/.objaverse_xl".
|
15 |
+
|
16 |
+
Returns:
|
17 |
+
pd.DataFrame: Smithsonian Object Metadata dataset as a Pandas DataFrame with
|
18 |
+
columns for the object "title", "url", "quality", and "file_type".
|
19 |
+
The quality is always Medium and the file_type is always glb.
|
20 |
+
"""
|
21 |
+
dirname = os.path.expanduser(os.path.join(download_dir, "smithsonian"))
|
22 |
+
os.makedirs(dirname, exist_ok=True)
|
23 |
+
filename = os.path.join(dirname, "object-metadata.parquet")
|
24 |
|
25 |
+
url = "https://huggingface.co/datasets/allenai/objaverse-xl/resolve/main/smithsonian/object-metadata.parquet"
|
26 |
+
response = requests.get(url)
|
27 |
+
response.raise_for_status()
|
28 |
+
with open(filename, "wb") as file:
|
29 |
+
file.write(response.content)
|
30 |
|
31 |
+
return pd.read_parquet(filename)
|
|