Repository: Project-MONAI/MONAI

Issue:
issue with LoadNifti & denseNet121 in V.0.5.0 
Previously the following codes was working 
but it showed error messages and could not continue: 

!pip install -q "monai[gdown, nibabel, tqdm]"

from monai.transforms import \
    Compose,  AddChanneld, ScaleIntensityd, ToTensord, RandRotated, RandFlipd, RandZoomd, Spacingd, SpatialPadd, CenterSpatialCropd , LoadNiftid  
from monai.networks.nets import densenet121

Below are the errors:

ImportError: cannot import name 'LoadNiftid' from 'monai.transforms' (/usr/local/lib/python3.7/dist-packages/monai/transforms/__init__.py)

ImportError: cannot import name 'densenet121' from 'monai.networks.nets' (/usr/local/lib/python3.7/dist-packages/monai/networks/nets/__init__.py)







Discussion:

Resolving patch:
diff --git a/monai/networks/nets/__init__.py b/monai/networks/nets/__init__.py
--- a/monai/networks/nets/__init__.py
+++ b/monai/networks/nets/__init__.py
@@ -13,7 +13,23 @@
 from .autoencoder import AutoEncoder
 from .basic_unet import BasicUNet, BasicUnet, Basicunet
 from .classifier import Classifier, Critic, Discriminator
-from .densenet import DenseNet, DenseNet121, DenseNet169, DenseNet201, DenseNet264
+from .densenet import (
+    DenseNet,
+    Densenet,
+    DenseNet121,
+    Densenet121,
+    DenseNet169,
+    Densenet169,
+    DenseNet201,
+    Densenet201,
+    DenseNet264,
+    Densenet264,
+    densenet,
+    densenet121,
+    densenet169,
+    densenet201,
+    densenet264,
+)
 from .dynunet import DynUNet, DynUnet, Dynunet
 from .efficientnet import EfficientNet, EfficientNetBN, drop_connect, get_efficientnet_image_size
 from .fullyconnectednet import FullyConnectedNet, VarFullyConnectedNet
diff --git a/monai/networks/nets/densenet.py b/monai/networks/nets/densenet.py
--- a/monai/networks/nets/densenet.py
+++ b/monai/networks/nets/densenet.py
@@ -314,3 +314,10 @@ def __init__(
         )
         if pretrained:
             print("Currently PyTorch Hub does not provide densenet264 pretrained models.")
+
+
+Densenet = densenet = DenseNet
+Densenet121 = densenet121 = DenseNet121
+Densenet169 = densenet169 = DenseNet169
+Densenet201 = densenet201 = DenseNet201
+Densenet264 = densenet264 = DenseNet264


Test patch:
diff --git a/tests/test_densenet.py b/tests/test_densenet.py
--- a/tests/test_densenet.py
+++ b/tests/test_densenet.py
@@ -17,7 +17,7 @@
 from parameterized import parameterized
 
 from monai.networks import eval_mode
-from monai.networks.nets import DenseNet121, DenseNet169, DenseNet201, DenseNet264
+from monai.networks.nets import DenseNet121, Densenet169, DenseNet264, densenet201
 from monai.utils import optional_import
 from tests.utils import skip_if_quick, test_script_save
 
@@ -51,11 +51,11 @@
 
 TEST_CASES = []
 for case in [TEST_CASE_1, TEST_CASE_2, TEST_CASE_3]:
-    for model in [DenseNet121, DenseNet169, DenseNet201, DenseNet264]:
+    for model in [DenseNet121, Densenet169, densenet201, DenseNet264]:
         TEST_CASES.append([model, *case])
 
 
-TEST_SCRIPT_CASES = [[model, *TEST_CASE_1] for model in [DenseNet121, DenseNet169, DenseNet201, DenseNet264]]
+TEST_SCRIPT_CASES = [[model, *TEST_CASE_1] for model in [DenseNet121, Densenet169, densenet201, DenseNet264]]
 
 
 TEST_PRETRAINED_2D_CASE_1 = [  # 4-channel 2D, batch 2