Skip to content

Commit 3511186

Browse files
Refactor import statements in app.py and monet_bundle_inference_operator.py for clarity
Signed-off-by: Simone Bendazzoli <[email protected]>
1 parent a7ba89f commit 3511186

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

examples/apps/ai_spleen_nnunet_seg_app/app.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
from monai.deploy.operators.dicom_seg_writer_operator import DICOMSegmentationWriterOperator, SegmentDescription
2323
from monai.deploy.operators.dicom_series_selector_operator import DICOMSeriesSelectorOperator
2424
from monai.deploy.operators.dicom_series_to_volume_operator import DICOMSeriesToVolumeOperator
25-
from monai.deploy.operators.monai_bundle_inference_operator import (
26-
BundleConfigNames,
27-
IOMapping,
28-
29-
)
25+
from monai.deploy.operators.monai_bundle_inference_operator import BundleConfigNames, IOMapping
3026
from monai.deploy.operators.monai_nnunet_bundle_inference_operator import MONetBundleInferenceOperator
3127
from monai.deploy.operators.stl_conversion_operator import STLConversionOperator
3228

monai/deploy/operators/monet_bundle_inference_operator.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
1111

12-
from monai.deploy.operators.monai_bundle_inference_operator import MonaiBundleInferenceOperator, get_bundle_config
13-
from monai.deploy.utils.importutil import optional_import
1412
from typing import Any, Dict, Tuple, Union
13+
1514
from monai.deploy.core import Image
15+
from monai.deploy.operators.monai_bundle_inference_operator import MonaiBundleInferenceOperator, get_bundle_config
16+
from monai.deploy.utils.importutil import optional_import
1617

1718
MONAI_UTILS = "monai.utils"
1819
nibabel, _ = optional_import("nibabel", "3.2.1")
@@ -44,12 +45,12 @@ class MONetBundleInferenceOperator(MonaiBundleInferenceOperator):
4445
This operator extends the `MonaiBundleInferenceOperator` to support nnUNet-specific
4546
configurations and prediction logic. It initializes the nnUNet predictor and provides
4647
a method for performing inference on input data.
47-
48+
4849
Attributes
4950
----------
5051
_nnunet_predictor : torch.nn.Module
5152
The nnUNet predictor module used for inference.
52-
53+
5354
Methods
5455
-------
5556
_init_config(config_names)
@@ -65,16 +66,14 @@ def __init__(
6566
**kwargs,
6667
):
6768

68-
6969
super().__init__(*args, **kwargs)
70-
71-
self._nnunet_predictor : torch.nn.Module = None
72-
73-
74-
def _init_config(self, config_names):
70+
71+
self._nnunet_predictor: torch.nn.Module = None
72+
73+
def _init_config(self, config_names):
7574

7675
super()._init_config(config_names)
77-
parser = get_bundle_config(str(self._bundle_path), config_names)
76+
parser = get_bundle_config(str(self._bundle_path), config_names)
7877
self._parser = parser
7978

8079
self._nnunet_predictor = parser.get_parsed_content("network_def")
@@ -83,7 +82,7 @@ def predict(self, data: Any, *args, **kwargs) -> Union[Image, Any, Tuple[Any, ..
8382
"""Predicts output using the inferer."""
8483

8584
self._nnunet_predictor.predictor.network = self._model_network
86-
#os.environ['nnUNet_def_n_proc'] = "1"
85+
# os.environ['nnUNet_def_n_proc'] = "1"
8786
if len(data.shape) == 4:
8887
data = data[None]
8988
return self._nnunet_predictor(data)

0 commit comments

Comments
 (0)