monai-weekly 1.5.dev2508__py3-none-any.whl → 1.5.dev2510__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- monai/__init__.py +1 -1
- monai/_version.py +3 -3
- monai/apps/deepedit/interaction.py +1 -1
- monai/apps/deepgrow/interaction.py +1 -1
- monai/apps/detection/networks/retinanet_detector.py +1 -1
- monai/apps/detection/networks/retinanet_network.py +5 -5
- monai/apps/detection/utils/box_coder.py +2 -2
- monai/apps/mmars/mmars.py +1 -1
- monai/apps/reconstruction/networks/blocks/varnetblock.py +1 -1
- monai/bundle/scripts.py +42 -20
- monai/data/dataset.py +2 -9
- monai/data/utils.py +1 -1
- monai/data/video_dataset.py +1 -1
- monai/engines/evaluator.py +11 -16
- monai/engines/trainer.py +11 -17
- monai/engines/utils.py +1 -1
- monai/engines/workflow.py +2 -2
- monai/fl/client/monai_algo.py +1 -1
- monai/handlers/checkpoint_loader.py +1 -1
- monai/inferers/inferer.py +35 -17
- monai/inferers/merger.py +16 -13
- monai/losses/perceptual.py +1 -1
- monai/losses/sure_loss.py +1 -1
- monai/networks/blocks/crossattention.py +1 -6
- monai/networks/blocks/feature_pyramid_network.py +4 -2
- monai/networks/blocks/selfattention.py +1 -6
- monai/networks/blocks/upsample.py +3 -11
- monai/networks/layers/vector_quantizer.py +2 -2
- monai/networks/nets/hovernet.py +5 -4
- monai/networks/nets/resnet.py +2 -2
- monai/networks/nets/senet.py +1 -1
- monai/networks/nets/swin_unetr.py +46 -49
- monai/networks/nets/transchex.py +3 -2
- monai/networks/nets/vista3d.py +7 -7
- monai/networks/utils.py +5 -4
- monai/transforms/intensity/array.py +1 -1
- monai/transforms/spatial/array.py +6 -6
- monai/utils/misc.py +1 -1
- monai/utils/state_cacher.py +1 -1
- {monai_weekly-1.5.dev2508.dist-info → monai_weekly-1.5.dev2510.dist-info}/METADATA +4 -3
- {monai_weekly-1.5.dev2508.dist-info → monai_weekly-1.5.dev2510.dist-info}/RECORD +60 -60
- {monai_weekly-1.5.dev2508.dist-info → monai_weekly-1.5.dev2510.dist-info}/WHEEL +1 -1
- tests/bundle/test_bundle_download.py +16 -6
- tests/config/test_cv2_dist.py +1 -2
- tests/inferers/test_controlnet_inferers.py +9 -0
- tests/integration/test_integration_bundle_run.py +2 -4
- tests/integration/test_integration_classification_2d.py +1 -1
- tests/integration/test_integration_fast_train.py +2 -2
- tests/integration/test_integration_segmentation_3d.py +1 -1
- tests/metrics/test_compute_multiscalessim_metric.py +3 -3
- tests/metrics/test_surface_dice.py +3 -3
- tests/networks/nets/test_autoencoderkl.py +1 -1
- tests/networks/nets/test_controlnet.py +1 -1
- tests/networks/nets/test_diffusion_model_unet.py +1 -1
- tests/networks/nets/test_network_consistency.py +1 -1
- tests/networks/nets/test_swin_unetr.py +1 -1
- tests/networks/nets/test_transformer.py +1 -1
- tests/networks/test_save_state.py +1 -1
- {monai_weekly-1.5.dev2508.dist-info → monai_weekly-1.5.dev2510.dist-info}/LICENSE +0 -0
- {monai_weekly-1.5.dev2508.dist-info → monai_weekly-1.5.dev2510.dist-info}/top_level.txt +0 -0
@@ -76,8 +76,7 @@ class TestBundleRun(unittest.TestCase):
|
|
76
76
|
)
|
77
77
|
with open(meta_file, "w") as f:
|
78
78
|
json.dump(
|
79
|
-
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "
|
80
|
-
f,
|
79
|
+
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "2.3.0", "numpy_version": "1.22.2"}, f
|
81
80
|
)
|
82
81
|
cmd = ["coverage", "run", "-m", "monai.bundle"]
|
83
82
|
# test both CLI entry "run" and "run_workflow"
|
@@ -114,8 +113,7 @@ class TestBundleRun(unittest.TestCase):
|
|
114
113
|
)
|
115
114
|
with open(meta_file, "w") as f:
|
116
115
|
json.dump(
|
117
|
-
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "
|
118
|
-
f,
|
116
|
+
{"version": "0.1.0", "monai_version": "1.1.0", "pytorch_version": "2.3.0", "numpy_version": "1.22.2"}, f
|
119
117
|
)
|
120
118
|
|
121
119
|
os.mkdir(scripts_dir)
|
@@ -166,7 +166,7 @@ def run_inference_test(root_dir, test_x, test_y, device="cuda:0", num_workers=10
|
|
166
166
|
model = DenseNet121(spatial_dims=2, in_channels=1, out_channels=len(np.unique(test_y))).to(device)
|
167
167
|
|
168
168
|
model_filename = os.path.join(root_dir, "best_metric_model.pth")
|
169
|
-
model.load_state_dict(torch.load(model_filename))
|
169
|
+
model.load_state_dict(torch.load(model_filename, weights_only=True))
|
170
170
|
y_true = []
|
171
171
|
y_pred = []
|
172
172
|
with eval_mode(model):
|
@@ -186,7 +186,7 @@ class IntegrationFastTrain(DistTestCase):
|
|
186
186
|
step += 1
|
187
187
|
optimizer.zero_grad()
|
188
188
|
# set AMP for training
|
189
|
-
with torch.
|
189
|
+
with torch.autocast("cuda"):
|
190
190
|
outputs = model(batch_data["image"])
|
191
191
|
loss = loss_function(outputs, batch_data["label"])
|
192
192
|
scaler.scale(loss).backward()
|
@@ -207,7 +207,7 @@ class IntegrationFastTrain(DistTestCase):
|
|
207
207
|
roi_size = (96, 96, 96)
|
208
208
|
sw_batch_size = 4
|
209
209
|
# set AMP for validation
|
210
|
-
with torch.
|
210
|
+
with torch.autocast("cuda"):
|
211
211
|
val_outputs = sliding_window_inference(val_data["image"], roi_size, sw_batch_size, model)
|
212
212
|
|
213
213
|
val_outputs = [post_pred(i) for i in decollate_batch(val_outputs)]
|
@@ -216,7 +216,7 @@ def run_inference_test(root_dir, device="cuda:0"):
|
|
216
216
|
).to(device)
|
217
217
|
|
218
218
|
model_filename = os.path.join(root_dir, "best_metric_model.pth")
|
219
|
-
model.load_state_dict(torch.load(model_filename))
|
219
|
+
model.load_state_dict(torch.load(model_filename, weights_only=True))
|
220
220
|
with eval_mode(model):
|
221
221
|
# resampling with align_corners=True or dtype=float64 will generate
|
222
222
|
# slight different results between PyTorch 1.5 an 1.6
|
@@ -32,7 +32,7 @@ class TestMultiScaleSSIMMetric(unittest.TestCase):
|
|
32
32
|
metric(preds, target)
|
33
33
|
result = metric.aggregate()
|
34
34
|
expected_value = 0.023176
|
35
|
-
self.
|
35
|
+
self.assertAlmostEqual(expected_value, result.item(), 4)
|
36
36
|
|
37
37
|
def test2d_uniform(self):
|
38
38
|
set_determinism(0)
|
@@ -45,7 +45,7 @@ class TestMultiScaleSSIMMetric(unittest.TestCase):
|
|
45
45
|
metric(preds, target)
|
46
46
|
result = metric.aggregate()
|
47
47
|
expected_value = 0.022655
|
48
|
-
self.
|
48
|
+
self.assertAlmostEqual(expected_value, result.item(), 4)
|
49
49
|
|
50
50
|
def test3d_gaussian(self):
|
51
51
|
set_determinism(0)
|
@@ -58,7 +58,7 @@ class TestMultiScaleSSIMMetric(unittest.TestCase):
|
|
58
58
|
metric(preds, target)
|
59
59
|
result = metric.aggregate()
|
60
60
|
expected_value = 0.061796
|
61
|
-
self.
|
61
|
+
self.assertAlmostEqual(expected_value, result.item(), 4)
|
62
62
|
|
63
63
|
def input_ill_input_shape2d(self):
|
64
64
|
metric = MultiScaleSSIMMetric(spatial_dims=3, weights=[0.5, 0.5])
|
@@ -82,7 +82,7 @@ class TestAllSurfaceDiceMetrics(unittest.TestCase):
|
|
82
82
|
expected_res0[1, 1] = np.nan
|
83
83
|
for b, c in np.ndindex(batch_size, n_class):
|
84
84
|
np.testing.assert_allclose(expected_res0[b, c], res0[b, c].cpu())
|
85
|
-
np.testing.
|
85
|
+
np.testing.assert_allclose(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
|
86
86
|
np.testing.assert_equal(not_nans.cpu(), torch.tensor(2))
|
87
87
|
|
88
88
|
def test_tolerance_euclidean_distance(self):
|
@@ -126,7 +126,7 @@ class TestAllSurfaceDiceMetrics(unittest.TestCase):
|
|
126
126
|
expected_res0[1, 1] = np.nan
|
127
127
|
for b, c in np.ndindex(batch_size, n_class):
|
128
128
|
np.testing.assert_allclose(expected_res0[b, c], res0[b, c].cpu())
|
129
|
-
np.testing.
|
129
|
+
np.testing.assert_allclose(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
|
130
130
|
np.testing.assert_equal(not_nans.cpu(), torch.tensor(2))
|
131
131
|
|
132
132
|
def test_tolerance_euclidean_distance_3d(self):
|
@@ -173,7 +173,7 @@ class TestAllSurfaceDiceMetrics(unittest.TestCase):
|
|
173
173
|
expected_res0[1, 1] = np.nan
|
174
174
|
for b, c in np.ndindex(batch_size, n_class):
|
175
175
|
np.testing.assert_allclose(expected_res0[b, c], res0[b, c].cpu())
|
176
|
-
np.testing.
|
176
|
+
np.testing.assert_allclose(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
|
177
177
|
np.testing.assert_equal(not_nans.cpu(), torch.tensor(2))
|
178
178
|
|
179
179
|
def test_tolerance_all_distances(self):
|
@@ -330,7 +330,7 @@ class TestAutoEncoderKL(unittest.TestCase):
|
|
330
330
|
weight_path = os.path.join(tmpdir, filename)
|
331
331
|
download_url(url=url, filepath=weight_path, hash_val=hash_val, hash_type=hash_type)
|
332
332
|
|
333
|
-
net.load_old_state_dict(torch.load(weight_path), verbose=False)
|
333
|
+
net.load_old_state_dict(torch.load(weight_path, weights_only=True), verbose=False)
|
334
334
|
|
335
335
|
|
336
336
|
if __name__ == "__main__":
|
@@ -208,7 +208,7 @@ class TestControlNet(unittest.TestCase):
|
|
208
208
|
weight_path = os.path.join(tmpdir, filename)
|
209
209
|
download_url(url=url, filepath=weight_path, hash_val=hash_val, hash_type=hash_type)
|
210
210
|
|
211
|
-
net.load_old_state_dict(torch.load(weight_path), verbose=False)
|
211
|
+
net.load_old_state_dict(torch.load(weight_path, weights_only=True), verbose=False)
|
212
212
|
|
213
213
|
|
214
214
|
if __name__ == "__main__":
|
@@ -578,7 +578,7 @@ class TestDiffusionModelUNet3D(unittest.TestCase):
|
|
578
578
|
weight_path = os.path.join(tmpdir, filename)
|
579
579
|
download_url(url=url, filepath=weight_path, hash_val=hash_val, hash_type=hash_type)
|
580
580
|
|
581
|
-
net.load_old_state_dict(torch.load(weight_path), verbose=False)
|
581
|
+
net.load_old_state_dict(torch.load(weight_path, weights_only=True), verbose=False)
|
582
582
|
|
583
583
|
|
584
584
|
if __name__ == "__main__":
|
@@ -128,7 +128,7 @@ class TestSWINUNETR(unittest.TestCase):
|
|
128
128
|
data_spec["url"], weight_path, hash_val=data_spec["hash_val"], hash_type=data_spec["hash_type"]
|
129
129
|
)
|
130
130
|
|
131
|
-
ssl_weight = torch.load(weight_path)["model"]
|
131
|
+
ssl_weight = torch.load(weight_path, weights_only=True)["model"]
|
132
132
|
net = SwinUNETR(**input_param)
|
133
133
|
dst_dict, loaded, not_loaded = copy_model_state(net, ssl_weight, filter_func=filter_swinunetr)
|
134
134
|
assert_allclose(dst_dict[key][:8], value, atol=1e-4, rtol=1e-4, type_test=False)
|
@@ -101,7 +101,7 @@ class TestDecoderOnlyTransformer(unittest.TestCase):
|
|
101
101
|
weight_path = os.path.join(tmpdir, filename)
|
102
102
|
download_url(url=url, filepath=weight_path, hash_val=hash_val, hash_type=hash_type)
|
103
103
|
|
104
|
-
net.load_old_state_dict(torch.load(weight_path), verbose=False)
|
104
|
+
net.load_old_state_dict(torch.load(weight_path, weights_only=True), verbose=False)
|
105
105
|
|
106
106
|
|
107
107
|
if __name__ == "__main__":
|
@@ -64,7 +64,7 @@ class TestSaveState(unittest.TestCase):
|
|
64
64
|
if kwargs is None:
|
65
65
|
kwargs = {}
|
66
66
|
save_state(src=src, path=path, create_dir=create_dir, atomic=atomic, func=func, **kwargs)
|
67
|
-
ckpt = dict(torch.load(path))
|
67
|
+
ckpt = dict(torch.load(path, weights_only=True))
|
68
68
|
for k in ckpt.keys():
|
69
69
|
self.assertIn(k, expected_keys)
|
70
70
|
|
File without changes
|
File without changes
|