Datasets:

Languages:
English
ArXiv:
License:
mattdeitke commited on
Commit
d9175b5
1 Parent(s): ba96af0

update default processes to cpu count

Browse files
Files changed (1) hide show
  1. objaverse_xl/objaverse_v1.py +10 -3
objaverse_xl/objaverse_v1.py CHANGED
@@ -4,6 +4,7 @@ import gzip
4
  import json
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
@@ -336,8 +337,10 @@ class SketchfabDownloader(ObjaverseSource):
336
  download_dir (Optional[str], optional): The base directory to download the
337
  object to. Supports all file systems supported by fsspec. If None, the
338
  objects will be removed after downloading. Defaults to "~/.objaverse".
339
- processes (int, optional): The number of processes to use to download
340
- the objects. Defaults to 1.
 
 
341
  handle_found_object (Optional[Callable], optional): Called when an object is
342
  successfully found and downloaded. Here, the object has the same sha256
343
  as the one that was downloaded with Objaverse-XL. If None, the object
@@ -384,6 +387,8 @@ class SketchfabDownloader(ObjaverseSource):
384
  hf_object_paths = self._load_object_paths(
385
  download_dir=download_dir if download_dir is not None else "~/.objaverse"
386
  )
 
 
387
 
388
  # make a copy of the objects so we don't modify the original
389
  objects = objects.copy()
@@ -456,7 +461,9 @@ class SketchfabDownloader(ObjaverseSource):
456
  (item["fileIdentifier"], hf_object_paths[uid], item["sha256"])
457
  )
458
 
459
- logger.info(f"Downloading {len(objects_to_download)} new objects")
 
 
460
 
461
  # check if all objects are already downloaded
462
  if len(objects_to_download) == 0:
 
4
  import json
5
  import os
6
  import urllib.request
7
+ import multiprocessing
8
  from multiprocessing import Pool
9
  from typing import Any, Dict, List, Optional, Tuple, Callable
10
  import requests
 
337
  download_dir (Optional[str], optional): The base directory to download the
338
  object to. Supports all file systems supported by fsspec. If None, the
339
  objects will be removed after downloading. Defaults to "~/.objaverse".
340
+ processes (Optional[int], optional): The number of processes to use to
341
+ download the objects. If None, the number of processes will be set to
342
+ the number of CPUs on the machine (multiprocessing.cpu_count()).
343
+ Defaults to None.
344
  handle_found_object (Optional[Callable], optional): Called when an object is
345
  successfully found and downloaded. Here, the object has the same sha256
346
  as the one that was downloaded with Objaverse-XL. If None, the object
 
387
  hf_object_paths = self._load_object_paths(
388
  download_dir=download_dir if download_dir is not None else "~/.objaverse"
389
  )
390
+ if processes is None:
391
+ processes = multiprocessing.cpu_count()
392
 
393
  # make a copy of the objects so we don't modify the original
394
  objects = objects.copy()
 
461
  (item["fileIdentifier"], hf_object_paths[uid], item["sha256"])
462
  )
463
 
464
+ logger.info(
465
+ f"Downloading {len(objects_to_download)} new objects across {processes} processes"
466
+ )
467
 
468
  # check if all objects are already downloaded
469
  if len(objects_to_download) == 0: