|
28 | 28 | from monai.data import DataLoader, Dataset, partition_dataset
|
29 | 29 | from monai.data.utils import no_collation
|
30 | 30 | from monai.transforms import Compose, EnsureTyped, LoadImaged, Orientationd
|
31 |
| -from monai.utils import StrEnum, min_version, optional_import |
| 31 | +from monai.utils import ImageMetaKey, StrEnum, min_version, optional_import |
32 | 32 | from monai.utils.enums import DataStatsKeys, ImageStatsKeys
|
33 | 33 |
|
34 | 34 |
|
@@ -343,19 +343,25 @@ def _get_all_case_stats(
|
343 | 343 | d = summarizer(batch_data)
|
344 | 344 | except BaseException as err:
|
345 | 345 | if "image_meta_dict" in batch_data.keys():
|
346 |
| - filename = batch_data["image_meta_dict"]["filename_or_obj"] |
| 346 | + filename = batch_data["image_meta_dict"][ImageMetaKey.FILENAME_OR_OBJ] |
347 | 347 | else:
|
348 |
| - filename = batch_data[self.image_key].meta["filename_or_obj"] |
| 348 | + filename = batch_data[self.image_key].meta[ImageMetaKey.FILENAME_OR_OBJ] |
349 | 349 | logger.info(f"Unable to process data {filename} on {device}. {err}")
|
350 | 350 | if self.device.type == "cuda":
|
351 | 351 | logger.info("DataAnalyzer `device` set to GPU execution hit an exception. Falling back to `cpu`.")
|
352 |
| - batch_data[self.image_key] = batch_data[self.image_key].to("cpu") |
353 |
| - if self.label_key is not None: |
354 |
| - label = batch_data[self.label_key] |
355 |
| - if not _label_argmax: |
356 |
| - label = torch.argmax(label, dim=0) if label.shape[0] > 1 else label[0] |
357 |
| - batch_data[self.label_key] = label.to("cpu") |
358 |
| - d = summarizer(batch_data) |
| 352 | + try: |
| 353 | + batch_data[self.image_key] = batch_data[self.image_key].to("cpu") |
| 354 | + if self.label_key is not None: |
| 355 | + label = batch_data[self.label_key] |
| 356 | + if not _label_argmax: |
| 357 | + label = torch.argmax(label, dim=0) if label.shape[0] > 1 else label[0] |
| 358 | + batch_data[self.label_key] = label.to("cpu") |
| 359 | + d = summarizer(batch_data) |
| 360 | + except BaseException as err: |
| 361 | + logger.info(f"Unable to process data {filename} on {device}. {err}") |
| 362 | + continue |
| 363 | + else: |
| 364 | + continue |
359 | 365 |
|
360 | 366 | stats_by_cases = {
|
361 | 367 | DataStatsKeys.BY_CASE_IMAGE_PATH: d[DataStatsKeys.BY_CASE_IMAGE_PATH],
|
|
0 commit comments