Skip to content

Commit 5b7b45c

Browse files
authored
Support update nuclio cvat model from bundle (#1080)
1 parent 92b7f21 commit 5b7b45c

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

sample-apps/endoscopy/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,17 @@ monailabel start_server \
124124
--conf auto_finetune_check_interval 30
125125
```
126126

127-
#### Update/Publish latest model back to CVAT
127+
#### Fetch and Publish latest model to CVAT/Nuclio
128128
After re-train the fine-tuned model meets all the conditions to be considered as a good model. You can push the model to cvat/nuclio function container.
129129
```bash
130-
workspace/endoscopy/update_cvat_model.sh <FUNCTION_NAME> <MODEL_PATH>
131-
132-
# publish tool tracking model (run this command on the node where cvat/nuclio containers are running)
133-
workspace/endoscopy/update_cvat_model.sh tootracking ./workspace/endoscopy/model/tooltracking.pt
134-
130+
workspace/endoscopy/update_cvat_model.sh <FUNCTION_NAME>
131+
132+
# Bundle Example: publish tool tracking bundle trained model (run this command on the node where cvat/nuclio containers are running)
133+
workspace/endoscopy/update_cvat_model.sh tootracking
134+
# Bundle Example: publish inbody trained model
135+
workspace/endoscopy/update_cvat_model.sh inbody
136+
# DeepEdit Example: publish deepedit trained model (Not from bundle)
137+
workspace/endoscopy/update_cvat_model.sh deepedit
135138
```
136139

137140
Following are additional configs *(pass them as **--conf name value**) are useful when you use CVAT for Active Learning workflow.

sample-apps/endoscopy/update_cvat_model.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
# bash /bin/update_cvat_model.sh <FUNCTION_NAME> <MODEL_PATH>
1616

1717
FUNC_NAME=$1
18-
MODEL_PATH=$2
18+
19+
APP_ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
20+
21+
# Hash table for bundle names
22+
declare -A BUNDLENAMES=( ["inbody"]="endoscopic_inbody_classification" ["tooltracking"]="endoscopic_tool_segmentation")
1923

2024
if [ $# -eq 0 ];then
2125
echo "Usage: No function name provided, exiting..."
@@ -30,15 +34,23 @@ if [ ! $(docker inspect -f '{{.State.Status}}' $FUNC_CONTAINER) == "running" ];
3034
echo "$FUNC_CONTAINER container is not running, can not publish to container..."
3135
fi
3236

33-
# default published model name
34-
MODEL_CONTAINER="/opt/conda/monailabel/sample-apps/endoscopy/model/pretrained_$FUNC_NAME.pt" # default model path at function container
37+
# Fetch latest model
38+
if [ $FUNC_NAME == "deepedit" ];then
39+
MODEL_PATH="$APP_ROOT/model/$FUNC_NAME.pt"
40+
# Replace prior pretrained model with lastest model as current pre-trained model
41+
MODEL_CONTAINER="/opt/conda/monailabel/sample-apps/endoscopy/model/pretrained_$FUNC_NAME.pt" # default model path at function container
42+
else
43+
# if bundle is used, get bundle name and fetch the model
44+
BUNDLE_NAME=${BUNDLENAMES[$FUNC_NAME]}
45+
MODEL_PATH="$APP_ROOT/model/$BUNDLE_NAME/models/model.pt"
46+
# Update to bundle nuclio container
47+
MODEL_CONTAINER="/opt/conda/monailabel/sample-apps/endoscopy/model/$BUNDLE_NAME/models/model_new2.pt" # default model path at function container
48+
fi
3549

36-
# Check if latest model checkpoint is done and saved, error if blank.
50+
# Check if latest model checkpoint is done and saved.
3751
if [ -z "$MODEL_PATH" ] || [ ! -f "$MODEL_PATH" ]; then
3852
echo "Latest model checkpoint not provided or published, exiting..."
3953
else
40-
# Replace prior pretrained model with lastest model as current pre-trained model
4154
$(docker cp "$MODEL_PATH" "$FUNC_CONTAINER:$MODEL_CONTAINER")
42-
echo "Published latest mode: $MODEL_PATH into $FUNC_NAME nuclio function container."
43-
fi
44-
55+
echo "Fetched and Published latest model: $FUNC_NAME to the nuclio function container."
56+
fi

0 commit comments

Comments
 (0)