Skip to content

Add TorchScript model (model.ts) for Swin UNETR segmentation #747

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

cvbourne
Copy link

Fixes # .

Description

This PR adds a traced TorchScript model (model.ts) to address issue #511 in the monai-deploy-app-sdk repository, where the ai_unetr_seg_app example cannot run due to a missing traced model. The original error in the app was:
monai.deploy.exceptions.ItemNotExistsError: A predictor of the model is not set.
The example app expects a TorchScript model, but the current model provided in the Model Zoo (model_swin_unetr_btcv_segmentation_v1.pt) is a standard PyTorch model, not a TorchScript format.

Solution
I've created a traced version of the Swin UNETR BTCV segmentation model by:

Loading the original model's state dictionary
Creating a new SwinUNETR instance with the correct parameters
Tracing the model using torch.jit.trace with appropriate input dimensions
Preparing the necessary model file structure according to Model Zoo guidelines

Status

Ready

Please ensure all the checkboxes:

  • 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").

@cvbourne
Copy link
Author

@MMelQin In case you'd like to review as well.

@yiheng-wang-nv
Copy link
Collaborator

Hi @cvbourne , thanks for the PR, could you also update the change log and version in the modified bundle's metadata.json? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants