Skip to content

Commit 2b8bffd

Browse files
authored
Merge branch 'dev' into bugfix/attention-remove-unused-parameters
2 parents 955dc53 + f27517b commit 2b8bffd

File tree

89 files changed

+3563
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3563
-614
lines changed

docs/source/apps.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,15 @@ FastMRIReader
277277

278278
.. autoclass:: monai.apps.nnunet.nnUNetV2Runner
279279
:members:
280+
281+
`nnUNet Bundle`
282+
---------------
283+
.. autoclass:: monai.apps.nnunet.ModelnnUNetWrapper
284+
:members:
285+
:special-members:
286+
287+
.. autofunction:: monai.apps.nnunet.get_nnunet_trainer
288+
.. autofunction:: monai.apps.nnunet.get_nnunet_monai_predictor
289+
.. autofunction:: monai.apps.nnunet.convert_nnunet_to_monai_bundle
290+
.. autofunction:: monai.apps.nnunet.convert_monai_bundle_to_nnunet
291+
.. autofunction:: monai.apps.nnunet.get_network_from_nnunet_plans

docs/source/bundle.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Model Bundle
3434
:members:
3535
:special-members:
3636

37+
3738
`Scripts`
3839
---------
3940
.. autofunction:: ckpt_export

docs/source/networks.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ Blocks
109109
.. autoclass:: SABlock
110110
:members:
111111

112+
`CABlock Block`
113+
~~~~~~~~~~~~~~~
114+
.. autoclass:: CABlock
115+
:members:
116+
117+
`FeedForward Block`
118+
~~~~~~~~~~~~~~~~~~~
119+
.. autoclass:: FeedForward
120+
:members:
121+
112122
`Squeeze-and-Excitation`
113123
~~~~~~~~~~~~~~~~~~~~~~~~
114124
.. autoclass:: ChannelSELayer
@@ -173,6 +183,16 @@ Blocks
173183
.. autoclass:: Subpixelupsample
174184
.. autoclass:: SubpixelUpSample
175185

186+
`Downsampling`
187+
~~~~~~~~~~~~~~
188+
.. autoclass:: DownSample
189+
:members:
190+
.. autoclass:: Downsample
191+
.. autoclass:: SubpixelDownsample
192+
:members:
193+
.. autoclass:: Subpixeldownsample
194+
.. autoclass:: SubpixelDownSample
195+
176196
`Registration Residual Conv Block`
177197
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178198
.. autoclass:: RegistrationResidualConvBlock
@@ -625,6 +645,11 @@ Nets
625645
.. autoclass:: ViT
626646
:members:
627647

648+
`Restormer`
649+
~~~~~~~~~~~
650+
.. autoclass:: restormer
651+
:members:
652+
628653
`ViTAutoEnc`
629654
~~~~~~~~~~~~
630655
.. autoclass:: ViTAutoEnc
@@ -750,3 +775,38 @@ Utilities
750775

751776
.. automodule:: monai.apps.reconstruction.networks.nets.utils
752777
:members:
778+
779+
Noise Schedulers
780+
----------------
781+
.. automodule:: monai.networks.schedulers
782+
.. currentmodule:: monai.networks.schedulers
783+
784+
`Scheduler`
785+
~~~~~~~~~~~
786+
.. autoclass:: Scheduler
787+
:members:
788+
789+
`NoiseSchedules`
790+
~~~~~~~~~~~~~~~~
791+
.. autoclass:: NoiseSchedules
792+
:members:
793+
794+
`DDPMScheduler`
795+
~~~~~~~~~~~~~~~
796+
.. autoclass:: DDPMScheduler
797+
:members:
798+
799+
`DDIMScheduler`
800+
~~~~~~~~~~~~~~~
801+
.. autoclass:: DDIMScheduler
802+
:members:
803+
804+
`PNDMScheduler`
805+
~~~~~~~~~~~~~~~
806+
.. autoclass:: PNDMScheduler
807+
:members:
808+
809+
`RFlowScheduler`
810+
~~~~~~~~~~~~~~~~
811+
.. autoclass:: RFlowScheduler
812+
:members:

monai/apps/deepedit/interaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __call__(self, engine: SupervisedTrainer | SupervisedEvaluator, batchdata: d
7272

7373
with torch.no_grad():
7474
if engine.amp:
75-
with torch.cuda.amp.autocast():
75+
with torch.autocast("cuda"):
7676
predictions = engine.inferer(inputs, engine.network)
7777
else:
7878
predictions = engine.inferer(inputs, engine.network)

monai/apps/deepgrow/interaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __call__(self, engine: SupervisedTrainer | SupervisedEvaluator, batchdata: d
6767
engine.network.eval()
6868
with torch.no_grad():
6969
if engine.amp:
70-
with torch.cuda.amp.autocast():
70+
with torch.autocast("cuda"):
7171
predictions = engine.inferer(inputs, engine.network)
7272
else:
7373
predictions = engine.inferer(inputs, engine.network)

monai/apps/detection/networks/retinanet_detector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def forward(self, images: torch.Tensor):
180180
nesterov=True,
181181
)
182182
torch.save(detector.network.state_dict(), 'model.pt') # save model
183-
detector.network.load_state_dict(torch.load('model.pt')) # load model
183+
detector.network.load_state_dict(torch.load('model.pt', weights_only=True)) # load model
184184
"""
185185

186186
def __init__(

monai/apps/detection/networks/retinanet_network.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def __init__(
8888

8989
for layer in self.conv.children():
9090
if isinstance(layer, conv_type): # type: ignore
91-
torch.nn.init.normal_(layer.weight, std=0.01)
92-
torch.nn.init.constant_(layer.bias, 0)
91+
torch.nn.init.normal_(layer.weight, std=0.01) # type: ignore[arg-type]
92+
torch.nn.init.constant_(layer.bias, 0) # type: ignore[arg-type]
9393

9494
self.cls_logits = conv_type(in_channels, num_anchors * num_classes, kernel_size=3, stride=1, padding=1)
9595
torch.nn.init.normal_(self.cls_logits.weight, std=0.01)
@@ -167,8 +167,8 @@ def __init__(self, in_channels: int, num_anchors: int, spatial_dims: int):
167167

168168
for layer in self.conv.children():
169169
if isinstance(layer, conv_type): # type: ignore
170-
torch.nn.init.normal_(layer.weight, std=0.01)
171-
torch.nn.init.zeros_(layer.bias)
170+
torch.nn.init.normal_(layer.weight, std=0.01) # type: ignore[arg-type]
171+
torch.nn.init.zeros_(layer.bias) # type: ignore[arg-type]
172172

173173
def forward(self, x: list[Tensor]) -> list[Tensor]:
174174
"""
@@ -297,7 +297,7 @@ def __init__(
297297
)
298298
self.feature_extractor = feature_extractor
299299

300-
self.feature_map_channels: int = self.feature_extractor.out_channels
300+
self.feature_map_channels: int = self.feature_extractor.out_channels # type: ignore[assignment]
301301
self.num_anchors = num_anchors
302302
self.classification_head = RetinaNetClassificationHead(
303303
self.feature_map_channels, self.num_anchors, self.num_classes, spatial_dims=self.spatial_dims

monai/apps/detection/utils/box_coder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ def decode_single(self, rel_codes: Tensor, reference_boxes: Tensor) -> Tensor:
221221

222222
pred_ctr_xyx_axis = dxyz_axis * whd_axis[:, None] + ctr_xyz_axis[:, None]
223223
pred_whd_axis = torch.exp(dwhd_axis) * whd_axis[:, None]
224-
pred_whd_axis = pred_whd_axis.to(dxyz_axis.dtype)
224+
pred_whd_axis = pred_whd_axis.to(dxyz_axis.dtype) # type: ignore[union-attr]
225225

226226
# When convert float32 to float16, Inf or Nan may occur
227227
if torch.isnan(pred_whd_axis).any() or torch.isinf(pred_whd_axis).any():
228228
raise ValueError("pred_whd_axis is NaN or Inf.")
229229

230230
# Distance from center to box's corner.
231231
c_to_c_whd_axis = (
232-
torch.tensor(0.5, dtype=pred_ctr_xyx_axis.dtype, device=pred_whd_axis.device) * pred_whd_axis
232+
torch.tensor(0.5, dtype=pred_ctr_xyx_axis.dtype, device=pred_whd_axis.device) * pred_whd_axis # type: ignore[arg-type]
233233
)
234234

235235
pred_boxes.append(pred_ctr_xyx_axis - c_to_c_whd_axis)

monai/apps/generation/maisi/networks/autoencoderkl_maisi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
232232
if self.print_info:
233233
logger.info(f"Number of splits: {self.num_splits}")
234234

235+
if self.dim_split <= 1 and self.num_splits <= 1:
236+
x = self.conv(x)
237+
return x
238+
235239
# compute size of splits
236240
l = x.size(self.dim_split + 2)
237241
split_size = l // self.num_splits

monai/apps/mmars/mmars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def load_from_mmar(
241241
return torch.jit.load(_model_file, map_location=map_location)
242242

243243
# loading with `torch.load`
244-
model_dict = torch.load(_model_file, map_location=map_location)
244+
model_dict = torch.load(_model_file, map_location=map_location, weights_only=True)
245245
if weights_only:
246246
return model_dict.get(model_key, model_dict) # model_dict[model_key] or model_dict directly
247247

0 commit comments

Comments
 (0)