Skip to content

Conversation

@SimoneBendazzoli93
Copy link

This PR introduces support for the MONet Bundle (an nnUNet wrapper for the MONAI Bundle) into MONAI Deploy.

Key Features:

  • Added a new operator: MONetBundleInferenceOperator, extending MonaiBundleInferenceOperator

  • Included an example application demonstrating spleen segmentation using the MONetBundleInferenceOperator

@SimoneBendazzoli93 SimoneBendazzoli93 marked this pull request as ready for review June 17, 2025 12:50
@MMelQin MMelQin requested review from MMelQin, bluna301 and Copilot June 25, 2025 15:41

This comment was marked as outdated.

@MMelQin
Copy link
Collaborator

MMelQin commented Jun 27, 2025

@SimoneBendazzoli93 Please sign off the commits with the steps shown in the details of the DECO check error. Thanks.

@MMelQin MMelQin requested a review from Copilot June 27, 2025 00:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates the new MONetBundleInferenceOperator for nnUNet-based MONAI Bundles into MONAI Deploy and provides an example application demonstrating spleen segmentation.

  • Adds MONetBundleInferenceOperator subclassing the existing bundle inference operator to support nnUNet predictors.
  • Updates core operator file to fix a string method misuse and handle missing metadata.
  • Supplies a complete example app with requirements, pipeline code, and entrypoints.
Comments suppressed due to low confidence (2)

monai/deploy/operators/monet_bundle_inference_operator.py:1

  • [nitpick] The copyright year appears incorrect (2002); update to the current year or range (e.g., 2023).
# Copyright 2002 MONAI Consortium

examples/apps/ai_spleen_nnunet_seg_app/app.py:33

  • [nitpick] The class name has a typo with triple 'n' in AISpleennnUNetSegApp; consider renaming to AISpleenNnunetSegApp for clarity.
class AISpleennnUNetSegApp(Application):

nibabel>=3.2.1
torch>=1.12.0
nvflare
git+https://github.com/SimoneBendazzoli93/dynamic-network-architectures.git
Copy link

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Including dependencies directly from forks may hinder reproducibility; consider pinning to a stable release or official package versions.

Copilot uses AI. Check for mistakes.
MMelQin and others added 20 commits July 17, 2025 07:24
Signed-off-by: mmelqin <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: mmelqin <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
* Add the newly introduced example to readme.md

This is a a bit of a chicken-and-egg problem, since the readme.md refers
to the published latest version of the doc with which can only happen when
the release build is done, and this particular doc is part of the build,
included in the package to be pushed to pypi.org.

Next time, need to consider add the entry, with a placeholder/no-existent
URL prior to the release build, so that the content will show up in the new
package, and URL leads to valid content post build.

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

* Added verbiage to name but a few tutorials.

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…ONAI#316)

* DOC: Use upstream/downstream instead of source/destination

For monai.deploy.core.Operator, instead of sometimes using "upstream"
and "downstream" and sometimes using "source" and "destination",
consistently use former.

Signed-off-by: Lee Newberg <lee.newberg@kitware.com>

* DOC: Use source/destination instead of upstream/downstream

For monai.deploy.core.Operator, instead of sometimes using "upstream"
and "downstream" and sometimes using "source" and "destination",
consistently use the latter.

Signed-off-by: Lee Newberg <lee.newberg@kitware.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
* Implement highdicom seg operator

Signed-off-by: Chris Bridge <chrisbridge44@googlemail.com>

* Formatting fixes

Signed-off-by: Chris Bridge <chrisbridge44@googlemail.com>

* Typing fixes

Signed-off-by: Chris Bridge <chrisbridge44@googlemail.com>

* Update the Spleen App to use HighDicom Seg Writer.

The app is still not compatible with monai v0.9.1 as the app testing
revealed that to its Invert transform failed resample the predicted
image back to input image spacings. Also, the new Seg Writer impl is
strict on DICOM attribute VR conformance, and would throw exception
when the input DICOM instances have non-conformant attribute VR values.

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

* Fix isort error for ordering of imports

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

* Update doc strings and comments for seg label and algorithm name and version

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

* Pin moani==0.9.0 for now as 0.9.1 causes issues. Also pydicom to 2.3.0

as the use of highdicom require pydicom>=2.3.0

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

* Updated apps that have multiple segments

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

* Found the few missing codes, so avoided use of generic "Organ"

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

Signed-off-by: Chris Bridge <chrisbridge44@googlemail.com>
Signed-off-by: mmelqin <mingmelvinq@nvidia.com>
Co-authored-by: mmelqin <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…thers

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: mmelqin <mingmelvinq@nvidia.com>

Signed-off-by: mmelqin <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…roject-MONAI#337)

* Improve STL operator so the enclosing app obj can run repetitively with the new sample code

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fixing Flake8 complaints

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Ignore Flake8 B024: abstract base class, but it has no abstract methods

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Silence mypy complaint on types

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Quiet another mypy error.

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* MyPy complaint fix

Signed-off-by: M Q <mingmelvinq@nvidia.com>

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…roject-MONAI#345)

* Added support of matching instance level tags, and update liver seg

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix Flake8 complaint

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Still enable publish intermediate nii files.

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Corrections per review comments

Signed-off-by: M Q <mingmelvinq@nvidia.com>

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
* Added support of matching instance level tags, and update liver seg

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix Flake8 complaint

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Still enable publish intermediate nii files.

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Corrections per review comments

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Enhance attribute settings

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fixed styling complaints

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix MyPy complaint

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Use content sequence for section of text

Signed-off-by: M Q <mingmelvinq@nvidia.com>

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: kavink <kavink@nvidia.com>

Signed-off-by: kavink <kavink@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…roject-MONAI#360)

* Updated to be compitable with monai 1.0.0 and its MetaTensor

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Made bundle inference operator compatible with MetaTensor

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Removed the use of ToTensor from all apps.

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix MyPy complaints

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix isort complaint

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Use a constant for repeated use of monai.utils str literal; SonarCloud code smell.

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Updated Seg Writer and Spleen Seg Jupyter notebooks

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Minor to address comments and checker complaint

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Updated clara-viz Jupyter notebook and fixed checking complaint

Signed-off-by: M Q <mingmelvinq@nvidia.com>

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Andres <diazandr3s@gmail.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Andres <diazandr3s@gmail.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…SR Writer (Project-MONAI#366)

* Created dicom_utils for common obj and func, and added DICOM PDF Writer

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Formatting update

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix flake8 complaints

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Address mypy complaints

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Formatting

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Change to use full path of dicom_utils

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Replace Union with Optional

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Replace unused Union

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Update the year in the copyright notice

Signed-off-by: M Q <mingmelvinq@nvidia.com>

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
* Add the missing python package, PyPDF2

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Add PyPDF2>=2.11.1

Signed-off-by: M Q <mingmelvinq@nvidia.com>

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: M Q <mingmelvinq@nvidia.com>

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
SimoneBendazzoli93 and others added 16 commits July 17, 2025 07:24
…nference operator

Signed-off-by: Simone Bendazzoli <simben@kth.se>
…tor.py for clarity

Signed-off-by: Simone Bendazzoli <simben@kth.se>
…undle

Signed-off-by: Simone Bendazzoli <simben@kth.se>
…image

Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…ect module path

Signed-off-by: Simone Bendazzoli <simben@kth.se>
* hugging_face_integration_app dependency cleanup

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

* cchmc_ped_abd_ct_seg example app

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

* license update + code optimizations

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

* cleanup

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

* spelling + dependency cleanup

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

* model DICOM tag cleanup

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

---------

Signed-off-by: bluna301 <luna.bryanr@gmail.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…roject-MONAI#536)

* Adding requirements for Triton client impl

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Updated/added core classes to support Triton remote inference, and added a new example

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* GitHub build server complains about conflicts for tritonclient[]>=2.54 for no specific reasons

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix flake8 complaints

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix pytype complaints by simplifying code

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Remove now unused imports

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Addressed all pytype and mypy complaint in new code in the dev env

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* No complaint in local dev env, but on GitHub

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Add model confgi.pbtxt and example env settings

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Doc update

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* update license dates

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Updated the copyright year of new files

Signed-off-by: M Q <mingmelvinq@nvidia.com>

---------

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
* Prepared changes for releasing v3

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Bump the required version to 3.9

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Update Python version references to 3.9 in documentation and configuration files

- Updated .gitignore to include new input and test directories.
- Changed Python version from 3.8 to 3.9 in .readthedocs.yml, setup.cfg, and run script.
- Updated documentation to reflect the use of Python 3.9 in various tutorials.

Signed-off-by: M Q <mingmelvinq@nvidia.com>

---------

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
- Removed unnecessary logic in setup.py
- Fix versioneer issues

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
* Bump version: 2.0.0 → 3.0.0

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Bump version: 2.0.0 -> 3.0.0 with __init__.py fix

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Remove blank line complained by black

Signed-off-by: M Q <mingmelvinq@nvidia.com>

* Fix more formatting complaints

Signed-off-by: M Q <mingmelvinq@nvidia.com>

---------

Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
…NetBundleInferenceOperator

Signed-off-by: Simone Bendazzoli <simben@kth.se>
…pdate docstring

Signed-off-by: Simone Bendazzoli <simben@kth.se>
* series selector improvements

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

* PatientPosition tag check

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

* exclusion matching for set type

Signed-off-by: bluna301 <luna.bryanr@gmail.com>

---------

Signed-off-by: bluna301 <luna.bryanr@gmail.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: M Q <mingmelvinq@nvidia.com>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
@SimoneBendazzoli93 SimoneBendazzoli93 force-pushed the main branch 2 times, most recently from 677f748 to 3b127ed Compare July 17, 2025 07:57
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Signed-off-by: Simone Bendazzoli <simben@kth.se>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +86 to +87
multimodal_data[key] = ResampleToMatch(mode="bilinear")(kwargs[key], img_dst=data
)
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The line break in the middle of the function call parameters makes the code harder to read. Consider keeping the function call on a single line or using a more conventional line break pattern.

Suggested change
multimodal_data[key] = ResampleToMatch(mode="bilinear")(kwargs[key], img_dst=data
)
multimodal_data[key] = ResampleToMatch(mode="bilinear")(kwargs[key], img_dst=data)

Copilot uses AI. Check for mistakes.
model_network : torch.nn.Module or torch.jit.ScriptModule
The model network to be used for inference.
"""
if not isinstance(model_network, torch.nn.Module) and not torch.jit.isinstance(model_network, torch.jit.ScriptModule):
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isinstance check for torch.jit.ScriptModule should use isinstance() instead of torch.jit.isinstance(). The correct check would be: isinstance(model_network, torch.jit.ScriptModule)

Suggested change
if not isinstance(model_network, torch.nn.Module) and not torch.jit.isinstance(model_network, torch.jit.ScriptModule):
if not isinstance(model_network, torch.nn.Module) and not isinstance(model_network, torch.jit.ScriptModule):

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 2, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.