Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added trt_compile configs for vista2d and vista3d #632

Merged
merged 4 commits into from
Sep 3, 2024
Merged
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
2 changes: 1 addition & 1 deletion models/vista2d/configs/inference.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
256,
256
],
"input_dict": "${'image': '/home/venn/Desktop/data/medical/cellpose_dataset/test/001_img.png'}",
"input_dict": "${'image': '/cellpose_dataset/test/001_img.png'}",
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
"sam_ckpt_path": "$@ckpt_dir + '/sam_vit_b_01ec64.pth'",
"pretrained_ckpt_path": "$@ckpt_dir + '/model.pt'",
Expand Down
10 changes: 10 additions & 0 deletions models/vista2d/configs/inference_trt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"imports": [
"$import numpy",
"$from monai.networks import trt_compile"
],
"trt_args": {
yiheng-wang-nv marked this conversation as resolved.
Show resolved Hide resolved
"dynamic_batchsize": "$[1, @inferer#sw_batch_size, @inferer#sw_batch_size]"
},
"network": "$trt_compile(@network_def.to(@device), @pretrained_ckpt_path, args=@trt_args)"
}
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.3",
"version": "0.2.4",
"changelog": {
"0.2.4": "enable tensorrt inference",
"0.2.3": "update weights link",
"0.2.2": "update to use monai components",
"0.2.1": "initial OSS version"
Expand Down
8 changes: 7 additions & 1 deletion models/vista2d/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ torchrun --nproc_per_node=gpu -m monai.bundle run_workflow "scripts.workflow.Vis
python -m monai.bundle run --config_file configs/inference.json
```

Please note that the data used in the config file is: "/cellpose_dataset/test/001_img.png", if the dataset path is different or you want to do inference on another file, please modify in `configs/inference.json` accordingly.
Please note that the data used in this config file is: "/cellpose_dataset/test/001_img.png", if the dataset path is different or you want to do inference on another file, please modify in `configs/inference.json` accordingly.

#### Execute inference with the TensorRT model:

```
python -m monai.bundle run --config_file "['configs/inference.json', 'configs/inference_trt.json']"
```

### Execute multi-GPU inference
```bash
Expand Down
9 changes: 9 additions & 0 deletions models/vista3d/configs/inference_trt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"+imports": [
"$from monai.networks import trt_compile"
],
"trt_args": {
"dynamic_batchsize": "$[1, @inferer#sw_batch_size, @inferer#sw_batch_size]"
},
"network": "$trt_compile(@network_def.to(@device), @bundle_root + '/models/model.pt', args=@trt_args, submodule=['image_encoder.encoder', 'class_head'])"
}
3 changes: 2 additions & 1 deletion models/vista3d/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.4.3",
"version": "0.4.4",
"changelog": {
"0.4.4": "enable tensorrt inference",
"0.4.3": "fix CL and batch infer issues",
"0.4.2": "use MONAI components for network and utils",
"0.4.1": "initial OSS version"
Expand Down
7 changes: 7 additions & 0 deletions models/vista3d/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ This default is overridable by changing the input folder `input_dir`, or the inp

Set `"postprocessing#transforms#0#_disabled_": false` to move the postprocessing to cpu to reduce the GPU memory footprint.

#### Execute inference with the TensorRT model:

```
python -m monai.bundle run --config_file "['configs/inference.json', 'configs/inference_trt.json']"
```


## Automatic segmentation label prompts :
The mapping between organ name and label prompt is in the [json file](labels.json)

Expand Down
Loading