Skip to content

Commit

Permalink
Update Vista3d (Project-MONAI#668)
Browse files Browse the repository at this point in the history
Fixes # .

### Description
A few sentences describing the changes proposed in this pull request.

### Status
**Ready/Work in progress/Hold**

### Please ensure all the checkboxes:
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Codeformat tests passed locally by running `./runtests.sh
--codeformat`.
- [ ] In-line docstrings updated.
- [ ] Update `version` and `changelog` in `metadata.json` if changing an
existing bundle.
- [ ] Please ensure the naming rules in config files meet our
requirements (please refer to: `CONTRIBUTING.md`).
- [ ] Ensure versions of packages such as `monai`, `pytorch` and `numpy`
are correct in `metadata.json`.
- [ ] Descriptions should be consistent with the content, such as
`eval_metrics` of the provided weights and TorchScript modules.
- [ ] Files larger than 25MB are excluded and replaced by providing
download links in `large_file.yml`.
- [ ] Avoid using path that contains personal information within config
files (such as use `/home/your_name/` for `"bundle_root"`).

---------

Signed-off-by: Yiheng Wang <[email protected]>
  • Loading branch information
yiheng-wang-nv authored Sep 23, 2024
1 parent 8d4ca79 commit 7c83ec0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions ci/unit_tests/test_vista3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os
import shutil
import sys
Expand Down Expand Up @@ -441,6 +442,15 @@ def test_error_prompt_infer_config(self, override):
original_exception = runtime_error.__cause__
self.assertEqual(str(original_exception), override["error"])

@parameterized.expand([TEST_CASE_INFER])
def test_labels_dict(self, override):
bundle_root = override["bundle_root"]
label_dict_file = os.path.join(bundle_root, "docs/labels.json")
if not os.path.isfile(label_dict_file):
raise ValueError(f"labels.json not found in {bundle_root}")
with open(label_dict_file) as f:
_ = json.load(f)


if __name__ == "__main__":
loader = unittest.TestLoader()
Expand Down
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.9",
"version": "0.5.0",
"changelog": {
"0.5.0": "update json file link and add test",
"0.4.9": "fix oom issue and update readme",
"0.4.8": "use 0.3 overlap for inference",
"0.4.7": "update tensorrt benchmark results",
Expand Down
4 changes: 2 additions & 2 deletions models/vista3d/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ConfigParser.export_config_file(parser.config, json_name, indent=4)
### Configurations

#### `label_mappings`
The core concept of label_mapping is to convert ground-truth label index of each dataset to a unified class index. For example, "Spleen" in MSD09 groundtruth will be represented by 1, while in AbdomenCT-1K it's 3. We unified a global label index [`label_dict`](./labels.json) to represent all 132 classes, and create a label mapping to map those local index to this global index. So when a user is training on their own dataset, we need to know this mapping.
The core concept of label_mapping is to convert ground-truth label index of each dataset to a unified class index. For example, "Spleen" in MSD09 groundtruth will be represented by 1, while in AbdomenCT-1K it's 3. We unified a global label index (`docs/labels.json`) to represent all 132 classes, and create a label mapping to map those local index to this global index. So when a user is training on their own dataset, we need to know this mapping.

The current label mapping `[[1, 3]]` indicates that training labels' class indices `1` is mapped
to the VISTA model's class `3` (format `[[src_class_0, dst_class_0], [src_class_1, dst_class_1], ...]`). So during inference, "3" is used to segment spleen.
Expand Down Expand Up @@ -173,7 +173,7 @@ list(set([i+1 for i in range(132)]) - set([2,16,18,20,21,23,24,25,26,27,128,129,
- The `points` together with `label_prompts` for "Kidney", "Lung", "Bone" (class index [2, 20, 21]) are not allowed since those prompts will be divided into sub-categories (e.g. left kidney and right kidney). Use `points` for the sub-categories as defined in the `inference.json`.

### `label_prompt` and `label_dict`
The `label_dict` defined in [`labels.json`](../docs/labels.json) has in total 132 classes. However, there are 5 we do not support and we keep them due to legacy issue. So in total
The `label_dict` defined in `docs/labels.json` has in total 132 classes. However, there are 5 we do not support and we keep them due to legacy issue. So in total
VISTA3D support 127 classes.

```
Expand Down
4 changes: 3 additions & 1 deletion models/vista3d/large_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ large_files:
hash_val: "6ce45a8edde4400c5d28d5e74d7b61d5"
hash_type: "md5"
- path: "docs/labels.json"
url: "https://github.com/Project-MONAI/tutorials/blob/e66be5955d2b4f5959884ca026932762954b19c5/vista_3d/label_dict.json"
url: "https://raw.githubusercontent.com/Project-MONAI/tutorials/e66be5955d2b4f5959884ca026932762954b19c5/vista_3d/label_dict.json"
hash_val: "71ff501086a80fe973ab843d2f7974c2"
hash_type: "md5"

0 comments on commit 7c83ec0

Please sign in to comment.