How to create our owm monai bundle app? #490
Replies: 1 comment
-
Hi @ArpanGyawali sorry for the delay in answering. I saw the other question about deployment as well with app SDK. You can make a bundle from any network, so if you've adapted an existing bundle then the other elements that came with that bundle can be used for inference and deployment. I think the complaint from App SDK was the Torchscript issue pointed out in other responses. The save weights for your model is differnt from Torchscript which is an independent object that doesn't require code definition. That's what gets used as the "predictor" in deployment. We can create such a file in your bundle easily since you already have the python -m monai.bundle ckpt_export --net_id network_def --bundle_root . --meta_file configs/metadata.json --config_file configs/inference.json --filepath models/model.ts --ckpt_file models/model.pt --key_in_ckpt model If this doesn't work we can edit "run": [
"$@handlers[0](@evaluator)",
"$torch.jit.script(@network.cpu()).save(@bundle_root + '/models/model.ts')"
] This runs the handler to load weights and then saves the network as Torchscript. You can then invoke the bundle from within its root directory and run this script with: python -m monai.bundle run --bundle_root . --meta_file configs/metadata.json --config_file configs/inference.json This should produce the file Alternatively this bundle comes with the python -m monai.bundle run --bundle_root . --meta_file configs/metadata.json --config_file configs/inference.json --dataset_dir /some/place/with/niftis I realise there's a lot of content going on here but if you have a bundle together you can use that as a running program as it is, and bundles are independent of the model zoo. I have a PR that will be ready soon on the tutorials repo for better bundle walkthroughs if you may want to look at: Project-MONAI/tutorials#1493 |
Beta Was this translation helpful? Give feedback.
-
I have made adaptations to the spleen CT segmentation application from Monai label tool and repurposed it for a skull-stripping task. The model was trained using Monai's labeling tool and 3D Slicer on a dataset comprising 22 images. The results during inference have been promising.
My goal is to package the trained model into a Monai bundle. This would allow me to leverage the monai-deploy-app-sdk for deploying the bundle to perform inferences. I'm curious whether it's a requirement to solely utilize models available in the Monai model zoo for creating a Monai bundle. Alternatively, am I able to construct a custom model bundle application?
I would greatly appreciate any guidance or insights you could provide on this matter.
Beta Was this translation helpful? Give feedback.
All reactions