Skip to content

Commit

Permalink
Merge branch 'dev' into use-gpu-load-nifti
Browse files Browse the repository at this point in the history
  • Loading branch information
yiheng-wang-nv authored Nov 2, 2024
2 parents 2b78dbd + 7a5e69c commit ac679fc
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/blossom-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
if: |
github.event.comment.body == '/build' &&
(
github.actor == 'pxLi' ||
github.actor == 'YanxuanLiu' ||
github.actor == 'wendell-hom' ||
github.actor == 'wyli' ||
github.actor == 'Nic-Ma' ||
github.actor == 'yiheng-wang-nv' ||
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
python: python3.8
python: python3

ci:
autofix_prs: true
Expand Down
22 changes: 21 additions & 1 deletion ci/unit_tests/test_vista3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
TEST_CASE_INFER_MULTI_NEW_STR_PROMPT = [
{
"bundle_root": "models/vista3d",
"input_dict": {"label_prompt": ["new class 1", "new class 2", "new class 3"]},
"input_dict": {"label_prompt": ["new class 1"], "points": [[123, 212, 151]], "point_labels": [1]},
"patch_size": [32, 32, 32],
"checkpointloader#_disabled_": True, # do not load weights"
"initialize": ["$monai.utils.set_determinism(seed=123)"],
Expand Down Expand Up @@ -223,6 +223,26 @@
"error": "Label prompt can only be a single object if provided with point prompts.",
}
],
[
{
"bundle_root": "models/vista3d",
"input_dict": {"label_prompt": [16, 25, 26]},
"patch_size": [32, 32, 32],
"checkpointloader#_disabled_": True, # do not load weights"
"initialize": ["$monai.utils.set_determinism(seed=123)"],
"error": "Undefined label prompt detected. Provide point prompts for zero-shot.",
}
],
[
{
"bundle_root": "models/vista3d",
"input_dict": {"label_prompt": [136]},
"patch_size": [32, 32, 32],
"checkpointloader#_disabled_": True, # do not load weights"
"initialize": ["$monai.utils.set_determinism(seed=123)"],
"error": "Undefined label prompt detected. Provide point prompts for zero-shot.",
}
],
]


Expand Down
16 changes: 16 additions & 0 deletions models/model_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -1770,5 +1770,21 @@
"vista3d_v0.5.3": {
"checksum": "2bfd5fd915f985f5ae1e19dea4dc2b6967ae2048",
"source": "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting/vista3d/versions/0.5.3/files/vista3d_v0.5.3.zip"
},
"vista2d_v0.3.0": {
"checksum": "6b78becd6590506ce379a9c58b288c75bda59d60",
"source": "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting/vista2d/versions/0.3.0/files/vista2d_v0.3.0.zip"
},
"pathology_tumor_detection_v0.6.2": {
"checksum": "24352fe6210711b74a11eb70ca25ed7efefc7d31",
"source": "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting/pathology_tumor_detection/versions/0.6.2/files/pathology_tumor_detection_v0.6.2.zip"
},
"vista3d_v0.5.4": {
"checksum": "05c03492449cad23267f1b97fd39c4153edd58b6",
"source": "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting/vista3d/versions/0.5.4/files/vista3d_v0.5.4.zip"
},
"vista3d_v0.5.5": {
"checksum": "a4509e12c97042a86173c6bbd5fcfc0d2620c0ea",
"source": "https://api.ngc.nvidia.com/v2/models/nvidia/monaihosting/vista3d/versions/0.5.5/files/vista3d_v0.5.5.zip"
}
}
3 changes: 2 additions & 1 deletion models/pathology_tumor_detection/configs/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
"version": "0.6.1",
"version": "0.6.2",
"changelog": {
"0.6.2": "enhance readme for nccl timout issue",
"0.6.1": "fix multi-gpu issue",
"0.6.0": "use monai 1.4 and update large files",
"0.5.9": "update to use monai 1.3.1",
Expand Down
4 changes: 2 additions & 2 deletions models/pathology_tumor_detection/configs/train.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"_target_": "DataLoader",
"dataset": "@train#dataset",
"batch_size": 128,
"pin_memory": true,
"pin_memory": false,
"num_workers": 8
},
"inferer": {
Expand Down Expand Up @@ -325,7 +325,7 @@
"_target_": "DataLoader",
"dataset": "@validate#dataset",
"batch_size": 128,
"pin_memory": true,
"pin_memory": false,
"shuffle": false,
"num_workers": 8
},
Expand Down
8 changes: 8 additions & 0 deletions models/pathology_tumor_detection/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run --config

Please note that the distributed training-related options depend on the actual running environment; thus, users may need to remove `--standalone`, modify `--nnodes`, or do some other necessary changes according to the machine used. For more details, please refer to [pytorch's official tutorial](https://pytorch.org/tutorials/intermediate/ddp_tutorial.html).

**Note:** When using a container based on [PyTorch 24.0x](https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes), you may encounter random NCCL timeout errors. To address this issue, consider the following adjustments:

- Reduce the `num_workers`: Decreasing the number of data loader workers can help minimize these errors.
- Set `pin_memory` to `False`: Disabling pinned memory may reduce the likelihood of timeouts.
- Switch to the `gloo` backend: As a workaround, you can set the distributed training backend to `gloo` to avoid NCCL-related timeouts.

You can implement these settings by adding flags like `--train#dataloader#num_workers 0` or `--train#dataloader#pin_memory false`.

#### Execute inference

```
Expand Down
3 changes: 2 additions & 1 deletion models/vista2d/configs/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20240725.json",
"version": "0.2.9",
"version": "0.3.0",
"changelog": {
"0.3.0": "update readme",
"0.2.9": "fix unsupported data dtype in findContours",
"0.2.8": "remove relative path in readme",
"0.2.7": "enhance readme",
Expand Down
14 changes: 10 additions & 4 deletions models/vista2d/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,27 @@ The default dataset for training, validation, and inference is the [Cellpose](ht
Additionally, all data lists are available in the `datalists.zip` file located in the root directory of the bundle. Extract the contents of the `.zip` file to access the data lists.

### Dependencies
Please refer to `required_packages_version` in `configs/metadata.json` to install all necessary dependencies before executing.
Please refer to the `required_packages_version` section in `configs/metadata.json` to install all necessary dependencies before execution. If you’re using the MONAI container, you can simply run the commands below and ignore any "opencv-python-headless not installed" error message, as this package is already included in the container.

```
pip install fastremap==1.15.0 roifile==2024.5.24 natsort==8.4.0
pip install --no-deps cellpose
```

Important Note: if your environment already contains OpenCV, installing `cellpose` may lead to conflicts and produce errors such as:

```
AttributeError: partially initialized module 'cv2' has no attribute 'dnn' (most likely due to a circular import)
```

when executing. To resolve this issue, please uninstall OpenCV and then re-install `cellpose` with a command like:
To resolve this, uninstall `OpenCV` first, and then install `cellpose` using the following commands:

```Bash
pip uninstall -y opencv && rm /usr/local/lib/python3.x/dist-packages/cv2
pip uninstall -y opencv && rm /usr/local/lib/python3.*/dist-packages/cv2
```
Make sure to replace 3.* with your actual Python version (e.g., 3.10).

Alternatively, you can use the following command to install `cellpose` without its dependencies:
Alternatively, you can install `cellpose` without its dependencies to avoid potential conflicts:

```
pip install --no-deps cellpose
Expand Down
5 changes: 3 additions & 2 deletions models/vista3d/configs/inference_trt.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"base_path": null,
"+imports": [
"$from monai.networks import trt_compile"
],
Expand All @@ -8,11 +9,11 @@
"dynamic_batchsize": "$[1, @inferer#sw_batch_size, @inferer#sw_batch_size]"
},
"network_dev": "$@network_def.to(@device)",
"encoder": "$trt_compile(@network_dev, @bundle_root + '/models/model.pt', args=@network_trt_args, submodule=['image_encoder.encoder'])",
"encoder": "$trt_compile(@network_dev, @bundle_root + '/models/model.pt' if not @base_path else @base_path, args=@network_trt_args, submodule=['image_encoder.encoder'])",
"head_trt_args": {
"dynamic_batchsize": "$[1, 1, @max_prompt_size]",
"fallback": "$True"
},
"head": "$trt_compile(@network_dev, @bundle_root + '/models/model.pt', args=@head_trt_args, submodule=['class_head']) if @head_trt_enabled else @network_dev",
"head": "$trt_compile(@network_dev, @bundle_root + '/models/model.pt' if not @base_path else @base_path, args=@head_trt_args, submodule=['class_head']) if @head_trt_enabled else @network_dev",
"network": "$None if @encoder is None else @head"
}
4 changes: 3 additions & 1 deletion models/vista3d/configs/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20240725.json",
"version": "0.5.3",
"version": "0.5.5",
"changelog": {
"0.5.5": "add arg for trt compiler base path",
"0.5.4": "add undefined label prompt check",
"0.5.3": "update readme",
"0.5.2": "fix eval issue",
"0.5.1": "add description for zero-shot and upate eval",
Expand Down
4 changes: 4 additions & 0 deletions models/vista3d/scripts/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ def check_prompts_format(self, label_prompt, points, point_labels):
raise ValueError("Label prompt must be a list of single scalar, [1,2,3,4,...,].")
if not np.all([(x < 255).item() for x in label_prompt]):
raise ValueError("Current bundle only supports label prompt smaller than 255.")
if points is None:
supported_list = list({i + 1 for i in range(132)} - {16, 18, 129, 130, 131})
if not np.all([x in supported_list for x in label_prompt]):
raise ValueError("Undefined label prompt detected. Provide point prompts for zero-shot.")
else:
raise ValueError("Label prompt must be a list, [1,2,3,4,...,].")
# check points
Expand Down

0 comments on commit ac679fc

Please sign in to comment.