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)
| 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 | """ |