Datasets:

Languages:
English
ArXiv:
License:
mattdeitke commited on
Commit
1e35c61
1 Parent(s): 4829dc3

update sketchfab annotations for consistency

Browse files
Files changed (1) hide show
  1. objaverse_xl/objaverse_v1.py +41 -2
objaverse_xl/objaverse_v1.py CHANGED
@@ -5,14 +5,53 @@ import json
5
  import os
6
  import urllib.request
7
  from multiprocessing import Pool
8
- from typing import Any, Dict, List, Optional, Tuple
 
 
 
 
9
 
10
  import fsspec
11
  from loguru import logger
12
  from tqdm import tqdm
13
 
14
 
15
- def load_annotations(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  uids: Optional[List[str]] = None,
17
  download_dir: str = "~/.objaverse",
18
  ) -> Dict[str, Any]:
 
5
  import os
6
  import urllib.request
7
  from multiprocessing import Pool
8
+ from typing import Any, Dict, List, Optional, Tuple, Callable
9
+ import requests
10
+ import pandas as pd
11
+ import tempfile
12
+ from objaverse_xl.utils import get_file_hash
13
 
14
  import fsspec
15
  from loguru import logger
16
  from tqdm import tqdm
17
 
18
 
19
+ def load_annotations(download_dir: str = "~/.objaverse") -> pd.DataFrame:
20
+ """Load the annotations from the given directory.
21
+
22
+ Args:
23
+ download_dir (str, optional): The directory to load the annotations from.
24
+ Supports all file systems supported by fsspec. Defaults to
25
+ "~/.objaverse".
26
+
27
+ Returns:
28
+ pd.DataFrame: The annotations, which includes the columns "thingId", "fileId",
29
+ "filename", and "license".
30
+ """
31
+ remote_url = "https://huggingface.co/datasets/allenai/objaverse-xl/resolve/main/objaverse_v1/object-metadata.parquet"
32
+ download_path = os.path.join(
33
+ download_dir, "hf-objaverse-v1", "thingiverse-objects.parquet"
34
+ )
35
+ fs, path = fsspec.core.url_to_fs(download_path)
36
+
37
+ if not fs.exists(path):
38
+ fs.makedirs(os.path.dirname(path), exist_ok=True)
39
+ logger.info(f"Downloading {remote_url} to {download_path}")
40
+ response = requests.get(remote_url)
41
+ response.raise_for_status()
42
+ with fs.open(path, "wb") as file:
43
+ file.write(response.content)
44
+
45
+ # read the file with pandas and fsspec
46
+ with fs.open(download_path, "rb") as f:
47
+ annotations_df = pd.read_parquet(f)
48
+
49
+ annotations_df["metadata"] = "{}"
50
+
51
+ return annotations_df
52
+
53
+
54
+ def load_full_annotations(
55
  uids: Optional[List[str]] = None,
56
  download_dir: str = "~/.objaverse",
57
  ) -> Dict[str, Any]: