Skip to content

Commit 77d2d82

Browse files
committed
Autofix
Signed-off-by: Eric Kerfoot <[email protected]>
1 parent 502950b commit 77d2d82

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

monai/apps/nnunet/nnunet_bundle.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ def __init__(self, predictor: object, model_folder: Union[str, Path], model_name
182182
parameters = []
183183

184184
checkpoint = torch.load(
185-
join(Path(model_training_output_dir).parent, "nnunet_checkpoint.pth"), map_location=torch.device("cpu"), weights_only=True
185+
join(Path(model_training_output_dir).parent, "nnunet_checkpoint.pth"),
186+
map_location=torch.device("cpu"),
187+
weights_only=True,
186188
)
187189
trainer_name = checkpoint["trainer_name"]
188190
configuration_name = checkpoint["init_args"]["configuration"]
@@ -192,7 +194,9 @@ def __init__(self, predictor: object, model_folder: Union[str, Path], model_name
192194
else None
193195
)
194196
if Path(model_training_output_dir).joinpath(model_name).is_file():
195-
monai_checkpoint = torch.load(join(model_training_output_dir, model_name), map_location=torch.device("cpu"), weights_only=True)
197+
monai_checkpoint = torch.load(
198+
join(model_training_output_dir, model_name), map_location=torch.device("cpu"), weights_only=True
199+
)
196200
if "network_weights" in monai_checkpoint.keys():
197201
parameters.append(monai_checkpoint["network_weights"])
198202
else:
@@ -383,8 +387,12 @@ def convert_nnunet_to_monai_bundle(nnunet_config: dict, bundle_root_folder: str,
383387
dataset_name, f"{nnunet_trainer}__{nnunet_plans}__{nnunet_configuration}"
384388
)
385389

386-
nnunet_checkpoint_final = torch.load(Path(nnunet_model_folder).joinpath(f"fold_{fold}", "checkpoint_final.pth"), weights_only=True)
387-
nnunet_checkpoint_best = torch.load(Path(nnunet_model_folder).joinpath(f"fold_{fold}", "checkpoint_best.pth"), weights_only=True)
390+
nnunet_checkpoint_final = torch.load(
391+
Path(nnunet_model_folder).joinpath(f"fold_{fold}", "checkpoint_final.pth"), weights_only=True
392+
)
393+
nnunet_checkpoint_best = torch.load(
394+
Path(nnunet_model_folder).joinpath(f"fold_{fold}", "checkpoint_best.pth"), weights_only=True
395+
)
388396

389397
nnunet_checkpoint = {}
390398
nnunet_checkpoint["inference_allowed_mirroring_axes"] = nnunet_checkpoint_final["inference_allowed_mirroring_axes"]

tests/data/meta_tensor/test_meta_tensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_pickling(self):
245245
with tempfile.TemporaryDirectory() as tmp_dir:
246246
fname = os.path.join(tmp_dir, "im.pt")
247247
torch.save(m, fname)
248-
m2 = torch.load(fname, weights_only=True)
248+
m2 = torch.load(fname, weights_only=True)
249249
self.check(m2, m, ids=False)
250250

251251
@skip_if_no_cuda

0 commit comments

Comments
 (0)