Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/test-modified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ jobs:
python-version: '3.10'
- name: Install MONAI
id: monai-install
env:
PIP_NO_CACHE_DIR: "1"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
df -h
which python
python -m pip install -U pip wheel
python -m pip install torch torchvision torchaudio
# Force CPU-only PyTorch wheels so we don't download huge CUDA/nvidia-* wheels in CI.
# Keep PyPI available for torch's dependencies.
python -m pip install --index-url https://download.pytorch.org/whl/cpu --extra-index-url https://pypi.org/simple torch torchvision torchaudio

python -m pip install -r https://raw.githubusercontent.com/Project-MONAI/MONAI/dev/requirements-dev.txt
python -m pip install -r requirements.txt

BUILD_MONAI=0 python -m pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
# Avoid PEP517 build isolation (which can re-install torch and pull CUDA wheels).
BUILD_MONAI=0 python -m pip install --no-build-isolation git+https://github.com/Project-MONAI/MONAI#egg=MONAI
python -m pip list
- name: Notebook quick check
shell: bash
Expand Down
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
FastAPI Inference Service for MONAI Models

Expand Down
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/app/inference.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Inference Logic

Expand Down
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
FastAPI Application for MONAI Model Inference

Expand Down
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/app/model_loader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
MONAI Model Loader

Expand Down
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/app/schemas.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Pydantic Models for Request/Response Validation

Expand Down
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/examples/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Example Python Client for MONAI FastAPI Inference Service

Expand Down
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Test suite for MONAI FastAPI Inference Service
"""
11 changes: 11 additions & 0 deletions deployment/fastapi_inference/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
API Endpoint Tests

Expand Down
3 changes: 3 additions & 0 deletions generation/maisi/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 🚨🚨🚨 THIS FOLDER IS DEPRECATED (as of Oct 2025) 🚨🚨🚨
# 👉 Please switch to: [https://github.com/NVIDIA-Medtech/NV-Generate-CTMR/tree/main](https://github.com/NVIDIA-Medtech/NV-Generate-CTMR/tree/main)

# Medical AI for Synthetic Imaging (MAISI)
This example demonstrates the applications of training and validating NVIDIA MAISI, a 3D Latent Diffusion Model (LDM) capable of generating large CT images accompanied by corresponding segmentation masks. It supports variable volume size and voxel spacing and allows for the precise control of organ/tumor size.

Expand Down
75 changes: 4 additions & 71 deletions generation/maisi/maisi_inference_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "67e2019e-1556-41a6-95e8-5d1a65f8b3a1",
"metadata": {
"scrolled": true
Expand Down Expand Up @@ -104,14 +104,14 @@
"\n",
"import monai\n",
"import torch\n",
"from monai.apps import download_url\n",
"from monai.config import print_config\n",
"from monai.transforms import LoadImage, Orientation\n",
"from monai.utils import set_determinism\n",
"from scripts.sample import LDMSampler, check_input\n",
"from scripts.utils import define_instance\n",
"from scripts.utils_plot import find_label_center_loc, get_xyz_plot, show_image\n",
"from scripts.diff_model_setting import setup_logging\n",
"from scripts.download_model_data import download_model_data\n",
"\n",
"print_config()\n",
"\n",
Expand Down Expand Up @@ -170,7 +170,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "e3c12dcc",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -204,74 +204,7 @@
" os.makedirs(directory, exist_ok=True)\n",
"root_dir = tempfile.mkdtemp() if directory is None else directory\n",
"\n",
"# TODO: remove the `files` after the files are uploaded to the NGC\n",
"files = [\n",
" {\n",
" \"path\": \"models/autoencoder_epoch273.pt\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai/tutorials\"\n",
" \"/model_zoo/model_maisi_autoencoder_epoch273_alternative.pt\",\n",
" },\n",
" {\n",
" \"path\": \"models/mask_generation_autoencoder.pt\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai\" \"/tutorials/mask_generation_autoencoder.pt\",\n",
" },\n",
" {\n",
" \"path\": \"models/mask_generation_diffusion_unet.pt\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai\"\n",
" \"/tutorials/model_zoo/model_maisi_mask_generation_diffusion_unet_v2.pt\",\n",
" },\n",
" {\n",
" \"path\": \"configs/all_anatomy_size_condtions.json\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai/tutorials/all_anatomy_size_condtions.json\",\n",
" },\n",
" {\n",
" \"path\": \"datasets/all_masks_flexible_size_and_spacing_4000.zip\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai\"\n",
" \"/tutorials/all_masks_flexible_size_and_spacing_4000.zip\",\n",
" },\n",
"]\n",
"\n",
"if maisi_version == \"maisi3d-ddpm\":\n",
" files += [\n",
" {\n",
" \"path\": \"models/diff_unet_3d_ddpm.pt\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai/tutorials/model_zoo\"\n",
" \"/model_maisi_input_unet3d_data-all_steps1000size512ddpm_random_current_inputx_v1_alternative.pt\",\n",
" },\n",
" {\n",
" \"path\": \"models/controlnet_3d_ddpm.pt\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai/tutorials/model_zoo\"\n",
" \"/model_maisi_controlnet-20datasets-e20wl100fold0bc_noi_dia_fsize_current_alternative.pt\",\n",
" },\n",
" {\n",
" \"path\": \"configs/candidate_masks_flexible_size_and_spacing_3000.json\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai\"\n",
" \"/tutorials/candidate_masks_flexible_size_and_spacing_3000.json\",\n",
" },\n",
" ]\n",
"elif maisi_version == \"maisi3d-rflow\":\n",
" files += [\n",
" {\n",
" \"path\": \"models/diff_unet_3d_rflow.pt\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai/tutorials/\"\n",
" \"diff_unet_ckpt_rflow_epoch19350.pt\",\n",
" },\n",
" {\n",
" \"path\": \"models/controlnet_3d_rflow.pt\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai/tutorials/controlnet_rflow_epoch60.pt\",\n",
" },\n",
" {\n",
" \"path\": \"configs/candidate_masks_flexible_size_and_spacing_4000.json\",\n",
" \"url\": \"https://developer.download.nvidia.com/assets/Clara/monai\"\n",
" \"/tutorials/candidate_masks_flexible_size_and_spacing_4000.json\",\n",
" },\n",
" ]\n",
"else:\n",
" raise ValueError(f\"maisi_version has to be chosen from ['maisi3d-ddpm', 'maisi3d-rflow'], yet got {maisi_version}.\")\n",
"\n",
"for file in files:\n",
" file[\"path\"] = file[\"path\"] if \"datasets/\" not in file[\"path\"] else os.path.join(root_dir, file[\"path\"])\n",
" download_url(url=file[\"url\"], filepath=file[\"path\"])"
"download_model_data(maisi_version, root_dir)"
]
},
{
Expand Down
Loading
Loading