(self)
| 337 | yield out_patch |
| 338 | |
| 339 | def __iter__(self): |
| 340 | if self.cache: |
| 341 | cache_index = None |
| 342 | for image in super().__iter__(): |
| 343 | key = self.hash_func(image) |
| 344 | if key in self._hash_keys: |
| 345 | # if existing in cache, try to get the index in cache |
| 346 | cache_index = self._hash_keys.index(key) |
| 347 | if cache_index is None: |
| 348 | # no cache for this index, execute all the transforms directly |
| 349 | yield from self._generate_patches(self.patch_iter(image)) |
| 350 | else: |
| 351 | if self._cache is None: |
| 352 | raise RuntimeError( |
| 353 | "Cache buffer is not initialized, please call `set_data()` before epoch begins." |
| 354 | ) |
| 355 | data = self._cache[cache_index] |
| 356 | other = self._cache_other[cache_index] |
| 357 | |
| 358 | # load data from cache and execute from the first random transform |
| 359 | data = deepcopy(data) if self.copy_cache else data |
| 360 | yield from self._generate_patches(zip(data, other), start=self.first_random) |
| 361 | else: |
| 362 | for image in super().__iter__(): |
| 363 | yield from self._generate_patches(self.patch_iter(image)) |
| 364 | |
| 365 | |
| 366 | class PatchDataset(IterableDataset): |
nothing calls this directly
no test coverage detected