MONAI Pipeline Generator#550
Conversation
608e827 to
802691f
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new MONAI Pipeline Generator tool that automatically creates MONAI Deploy Application pipelines from MONAI models hosted on HuggingFace. The tool provides a CLI interface to discover, generate, and run medical imaging applications with minimal configuration.
Key changes include:
- Complete implementation of the pipeline generator with 44 discoverable models from HuggingFace
- Comprehensive test suite achieving 97% code coverage with 105 tests
- Full CLI support for listing models, generating applications, and running them
Reviewed Changes
Copilot reviewed 46 out of 47 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/pipeline-generator/pyproject.toml | Project configuration with dependencies and build settings |
| tools/pipeline-generator/pipeline_generator/ | Core module structure with generator, config, CLI, and templates |
| tools/pipeline-generator/tests/ | Comprehensive test suite covering all functionality |
| tools/pipeline-generator/pipeline_generator/templates/ | Jinja2 templates for generating application files |
| tools/pipeline-generator/pipeline_generator/cli/ | CLI commands for list, gen, and run operations |
Comments suppressed due to low confidence (1)
tools/pipeline-generator/pipeline_generator/generator/app_generator.py:99
- The regex pattern has an incorrect escape sequence. The backslash before the opening bracket should be properly escaped as
\/instead of\[to match the forward slash character correctly.
model_id_pattern = r"^(?!.*\.\.)(?!/)(?!.*//)(?!.*\/$)[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$"
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Signed-off-by: Victor Chang <vicchang@nvidia.com>
Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Introduced ImageOverlayWriter for blending segmentation masks onto RGB images and saving as PNG. - Updated ImageDirectoryLoader to support channel-first output configuration and improved file searching logic. - Adjusted documentation and examples to reflect the transition from Poetry to uv for command execution. - Updated various configuration files and templates to accommodate new features and dependencies. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Introduced PromptsLoaderOperator to read prompts from a YAML file and emit them sequentially. - Added Llama3VILAInferenceOperator for running inference with the Llama3-VILA-M3-3B model, supporting multiple output types. - Created VLMResultsWriterOperator to write results to disk based on the specified output type. - Updated configuration files and templates to integrate new operators and support custom input/output types. - Added unit tests for the new operators to ensure functionality and correctness. Signed-off-by: [Your Name] <your.email@example.com> Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Enhanced README with links to MONAI Deploy and MONAI Bundles for better clarity. - Clarified usage instructions and examples for generating applications from models. - Updated design documentation to reflect the correct Python version requirement (changed from 3.12 to 3.10). - Improved descriptions in the generated application structure and additional models section. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…ator Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Updated import statements in various operator files to use parentheses for better readability. - Cleaned up whitespace and formatting inconsistencies across multiple files, enhancing overall code clarity. - Ensured consistent handling of newlines and indentation in operator implementations and test files. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Introduced a new GitHub Actions workflow for testing the pipeline generator, including steps for setting up Python 3.10, installing dependencies, and running tests. - Updated the version of the pipeline-generator package from 0.1.0 to 1.0.0 in the uv.lock file. - Refactored import statements and improved code formatting in various files for better readability and consistency. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…tion - Moved the documentation for ImageOverlayWriter into the class docstring for better organization and clarity. - Improved the model_id validation logic in AppGenerator to prevent code injection and path traversal, ensuring stricter input checks. - Updated the generated application template to reflect changes in the channel_first logic. - Added unit tests to verify the correctness of the refactored channel_first logic. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…e generator - Updated the application class documentation to provide clearer descriptions of the vision-language model (VLM) functionality, including details on prompt processing and output generation. - Refined the version constraints for the pydicom dependency in the requirements template to ensure compatibility with future updates while maintaining support for existing features. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…ionality - Replaced ImageDirectoryLoader with a new GenericDirectoryScanner and ImageFileLoader for improved flexibility in file handling. - Updated operator imports in the application template to reflect the new structure. - Added unit tests for the GenericDirectoryScanner to ensure correct functionality, including edge cases for file detection and filtering. - Removed deprecated NiftiDirectoryLoader and ImageDirectoryLoader to streamline the codebase. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Removed deprecated operators from the MONAI Deploy SDK and updated the import paths in the application template to reflect the new structure. - Introduced new operators such as GenericDirectoryScanner and ImageFileLoader for improved file handling. - Enhanced the NiftiDataLoader to handle various dimensionalities correctly and added logging for unexpected shapes. - Updated the pipeline generator to include new operators and refined the requirements for dependencies in the configuration files. - Added comprehensive tests for the new operators and updated existing tests to ensure functionality and correctness. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Updated operator imports in the MONAI Deploy SDK to streamline the structure and improve readability. - Refined the NiftiDataLoader to ensure proper handling of various dimensionalities and added logging for unexpected shapes. - Enhanced the pipeline generator to include new operators and improved the handling of output types. - Cleaned up whitespace and formatting inconsistencies across multiple files for better code clarity. - Removed deprecated test files related to GenericDirectoryScanner and VLM operators to maintain a clean codebase. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Adjusted whitespace in print statements for better readability in the DICOM data loader operator. - Enhanced the error message in the AppGenerator class to improve clarity regarding valid model_id formats. - Corrected spacing in the file processing output of the generic directory scanner operator. - Removed unused import from the test_run_command module to clean up the code. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Deleted the __init__.py test file from the pipeline-generator tests directory to clean up the codebase and remove unused files. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Added type hints for lists and dictionaries in various operator classes to improve code readability and maintainability. - Updated import statements to include type ignoring for YAML to prevent type checking issues. - Refined the initialization of file lists in the GenericDirectoryScanner operator for better type safety. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Updated the CLI output to reflect "Verified" models instead of "Tested" for better clarity. - Added new model configurations for pancreas segmentation and spleen segmentation in the config file. - Implemented a method to organize downloaded bundle structures into the standard MONAI format, improving file management. - Enhanced dependency handling in the AppGenerator to resolve conflicts between configuration and metadata. - Added unit tests to verify the new bundle organization functionality and ensure correct behavior under various scenarios. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…nerator - Added functionality to ensure the bundle root is included in sys.path for script imports. - Introduced a new model configuration for pediatric abdominal CT segmentation in the config file. - Improved the organization of model files by preferring PyTorch models over TensorRT models and handling subdirectory structures. - Enhanced unit tests to verify the new model organization logic and ensure correct behavior under various scenarios. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…nceOperator - Introduced helper functions to streamline model loading from directory-based bundles and ensure proper configuration parsing. - Improved error handling for missing model files and configuration metadata. - Refactored the get_bundle_config function to utilize the new helper for better code organization and readability. - Updated the NiftiDataLoader to handle image dimensionalities more effectively using SimpleITK metadata. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…perator and NiftiDataLoader - Removed unnecessary whitespace in the MonaiBundleInferenceOperator to enhance readability. - Streamlined function definitions and logging statements in NiftiDataLoader for better organization and clarity. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Enhanced exception handling by capturing the original exception in model loading functions to provide clearer error messages. - Updated the handling of network instantiation errors to include the original exception context for better debugging. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Added TYPE_CHECKING imports for torch to improve type hinting and static analysis. - Utilized type casting for model loading return values to ensure proper type safety and clarity. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Updated type hints for device and return values in model loading functions to use the alias `torch_typing` for improved clarity and consistency. - Enhanced type safety by ensuring all model-related return types are correctly annotated. Signed-off-by: Victor Chang <vicchang@nvidia.com>
…image conversion - Updated bundle path handling to use `Path` objects for consistency and clarity. - Simplified image conversion logic by consolidating conditional checks into a single line for better readability. - Ensured that directory checks and model loading operations utilize the updated path handling. Signed-off-by: Victor Chang <vicchang@nvidia.com>
- Improved handling of different dimensional outputs during image conversion to maintain DICOM pixel data arrangement. - Added specific cases for 2D and 3D images to ensure correct axis handling and data type conversion. Signed-off-by: Victor Chang <vicchang@nvidia.com>
Signed-off-by: M Q <mingmelvinq@nvidia.com>
… actual code Signed-off-by: M Q <mingmelvinq@nvidia.com>
…ii loader Signed-off-by: M Q <mingmelvinq@nvidia.com>
|
|
Merging the pull request, and the tool can only work for all supported models once the App SDK minor release v3.2.0 for folder based MONAI bundle support is released. |



A new tool for creating a MONAI Deploy Application pipeline using a chosen MONAI model.
Tested MONAI models
❯ uv run pg list Fetching models from HuggingFace... INFO Checking TorchScript models from organization: MONAI INFO Checking TorchScript model: LGAI-EXAONE/EXAONEPath INFO Checking TorchScript model: LGAI-EXAONE/EXAONEPath-CRC-MSI-Predictor Available Models ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓ ┃ Model ID ┃ Name ┃ MONAI Bundle ┃ Status ┃ Downloads ┃ Likes ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩ │ MONAI/brats_mri_segmentation │ MONAI/brats_mri_segmentation │ ✓ Yes │ │ N/A │ 3 │ │ MONAI/endoscopic_inbody_classification │ MONAI/endoscopic_inbody_classification │ ✓ Yes │ │ N/A │ N/A │ │ MONAI/endoscopic_tool_segmentation │ MONAI/endoscopic_tool_segmentation │ ✓ Yes │ ✓ Verified │ N/A │ 2 │ │ MONAI/example_spleen_segmentation │ MONAI/example_spleen_segmentation │ ✓ Yes │ ✓ Verified │ N/A │ 6 │ │ MONAI/lung_nodule_ct_detection │ MONAI/lung_nodule_ct_detection │ ✓ Yes │ │ N/A │ 1 │ │ MONAI/multi_organ_segmentation │ MONAI/multi_organ_segmentation │ ✓ Yes │ ✓ Verified │ N/A │ N/A │ │ MONAI/pancreas_ct_dints_segmentation │ MONAI/pancreas_ct_dints_segmentation │ ✓ Yes │ ✓ Verified │ N/A │ N/A │ │ MONAI/pathology_nuclei_classification │ MONAI/pathology_nuclei_classification │ ✓ Yes │ │ N/A │ N/A │ │ MONAI/pathology_nuclick_annotation │ MONAI/pathology_nuclick_annotation │ ✓ Yes │ │ N/A │ 1 │ │ MONAI/pediatric_abdominal_ct_segmentati… │ MONAI/pediatric_abdominal_ct_segmentation │ ✓ Yes │ ✓ Verified │ N/A │ 1 │ │ MONAI/prostate_mri_anatomy │ MONAI/prostate_mri_anatomy │ ✓ Yes │ │ N/A │ N/A │ │ MONAI/spleen_ct_segmentation │ MONAI/spleen_ct_segmentation │ ✓ Yes │ ✓ Verified │ N/A │ N/A │ │ MONAI/spleen_deepedit_annotation │ MONAI/spleen_deepedit_annotation │ ✓ Yes │ │ N/A │ N/A │ │ MONAI/ventricular_short_axis_3label │ MONAI/ventricular_short_axis_3label │ ✓ Yes │ │ N/A │ 1 │ └──────────────────────────────────────────┴───────────────────────────────────────────┴──────────────┴────────────┴───────────┴───────┘ Total models: 14 (MONAI Bundles: 14, Verified: 6)To list all available models:
Unit Test/Coverage