MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _fill_cache

Method _fill_cache

monai/data/dataset.py:897–915  ·  view source on GitHub ↗

Compute and fill the cache content from data source. Args: indices: target indices in the `self.data` source to compute cache. if None, use the first `cache_num` items.

(self, indices=None)

Source from the content-addressed store, hash-verified

895 return
896
897 def _fill_cache(self, indices=None) -> list:
898 """
899 Compute and fill the cache content from data source.
900
901 Args:
902 indices: target indices in the `self.data` source to compute cache.
903 if None, use the first `cache_num` items.
904
905 """
906 if self.cache_num <= 0:
907 return []
908 if indices is None:
909 indices = list(range(self.cache_num))
910 if self.progress and not has_tqdm:
911 warnings.warn("tqdm is not installed, will not show the caching progress bar.")
912 with ThreadPool(self.num_workers) as p:
913 if self.progress and has_tqdm:
914 return list(tqdm(p.imap(self._load_cache_item, indices), total=len(indices), desc="Loading dataset"))
915 return list(p.imap(self._load_cache_item, indices))
916
917 def _load_cache_item(self, idx: int):
918 """

Callers 2

set_dataMethod · 0.95
__init__Method · 0.45

Calls 1

tqdmFunction · 0.85

Tested by

no test coverage detected