Skip to content

Commit 5a7cbd8

Browse files
rename deid to inbody + add perf summary for endoscopy (#1006)
* rename deid to inbody + add perf summary for endoscopy Signed-off-by: Sachidanand Alle <[email protected]> * fix version Signed-off-by: Sachidanand Alle <[email protected]> Signed-off-by: Sachidanand Alle <[email protected]>
1 parent df9de94 commit 5a7cbd8

File tree

10 files changed

+46
-31
lines changed

10 files changed

+46
-31
lines changed

docs/source/installation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ and supported visualization tools with latest release of MONAI Label. Weekly pre
2121

2222
Current Milestone Release of MONAI Label:
2323

24-
* `0.5.0 <https://pypi.org/project/monailabel/>`_
24+
* `0.5.1 <https://pypi.org/project/monailabel/>`_
2525

2626
MONAI Label Supported Stable Visualization Tools:
2727

docs/source/whatsnew.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
What's New
1616
==========
1717

18-
0.5.0
18+
0.5.1
1919
=====
2020
- Endoscopy Sample App
2121

2222
- Tool Tracking segmentation model
23-
- InBody vs OutBody (DeID) classification model
23+
- InBody vs OutBody classification model
2424
- DeepEdit interaction model for annotating tool
2525
- CVAT Integration to support automated workflow to run Active Learning Iterations
2626
- Improving performance for Radiology App

plugins/cvat/endoscopy/deid.yaml renamed to plugins/cvat/endoscopy/inbody.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
# limitations under the License.
1111

1212
metadata:
13-
name: monailabel.endoscopy.deid
13+
name: monailabel.endoscopy.inbody
1414
namespace: cvat
1515
annotations:
16-
name: DeID
16+
name: InBody
1717
type: detector
1818
framework: pytorch
1919
spec: |
@@ -29,15 +29,15 @@ spec:
2929
eventTimeout: 30s
3030

3131
build:
32-
image: cvat/monailabel.endoscopy.deid
32+
image: cvat/monailabel.endoscopy.inbody
3333
baseImage: projectmonai/monailabel:latest
3434

3535
directives:
3636
preCopy:
3737
- kind: ENV
3838
value: MONAI_LABEL_APP_DIR=/opt/conda/monailabel/sample-apps/endoscopy
3939
- kind: ENV
40-
value: MONAI_LABEL_MODELS=deid
40+
value: MONAI_LABEL_MODELS=inbody
4141
- kind: ENV
4242
value: PYTHONPATH=/opt/conda/monailabel/sample-apps/endoscopy
4343
- kind: ENV

sample-apps/endoscopy/README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Following are the models which are currently added into Endosocpy App:
8888
|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
8989
| [deepedit](#deepedit) | This model is based on DeepEdit: an algorithm that combines the capabilities of multiple models into one, allowing for both interactive and automated segmentation to label **Tool** among in-body images. |
9090
| [tooltracking](#tooltracking) | A standard (non-interactive) segmentation model to label **Tool** among in-body images. |
91-
| [deid](#deid) | A standard (non-interactive) classification model to determine **InBody** or **OutBody** images. |
91+
| [inbody](#inbody) | A standard (non-interactive) classification model to determine **InBody** or **OutBody** images. |
9292

9393
> If both models are enabled, then Active Learning strategy uses [tooltracking](#tooltracking) model to rank the images.
9494
@@ -187,10 +187,10 @@ This model is based on UNet for automated segmentation. This model works for sin
187187
- Output: 1 channel representing the segmented Tool
188188

189189

190-
#### [DeID](./lib/configs/deid.py)
190+
#### [InBody](./lib/configs/inbody.py)
191191

192192
This model is based on SEResNet50 for classification. This model determines if tool is present or not (in-body vs out-body).
193-
> monailabel start_server --app workspace/endoscopy --studies workspace/images --conf models deid
193+
> monailabel start_server --app workspace/endoscopy --studies workspace/images --conf models inbody
194194
195195
- Network: This model uses the [SEResNet50](https://docs.monai.io/en/latest/networks.html#seresnet50) as the default network.
196196
- Labels: `{ "InBody": 0, "OutBody": 1 }`
@@ -231,3 +231,17 @@ tasks in headless mode.
231231
export PYTHONPATH=workspace/endoscopy:$PYTHONPATH
232232
python workspace/endoscopy/main.py
233233
```
234+
235+
236+
### Performance Benchmarking
237+
238+
The performance benchmarking is done using MONAILabel server for endoscopy models.
239+
Following is summary of the same:
240+
241+
| Model | Pre | Infer | Post | Total | Remarks |
242+
|--------------|-----|-------|------|-------|-----------------------------------------------------------------------|
243+
| tooltracking | 60 | 40 | 71 | 171 | **_(pre)_** Load Image: 35 ms<br/>**_(post)_** Mask to Polygon: 68 ms |
244+
| inbody | 50 | 30 | 1 | 81 | **_(pre)_** Load Image: 35 ms |
245+
| deepedit | 38 | 28 | 40 | 106 | **_(pre)_** Load Image: 35 ms<br/>**_(post)_** Mask to Polygon: 32 ms |
246+
247+
> Latencies are in **milliseconds (ms)**; <br/>Input Image size: **1920 x 1080**

sample-apps/endoscopy/lib/configs/deid.py renamed to sample-apps/endoscopy/lib/configs/inbody.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
logger = logging.getLogger(__name__)
3030

3131

32-
class DeID(TaskConfig):
32+
class InBody(TaskConfig):
3333
def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **kwargs):
3434
super().init(name, model_dir, conf, planner, **kwargs)
3535

@@ -44,7 +44,7 @@ def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **
4444

4545
# Download PreTrained Model
4646
if strtobool(self.conf.get("use_pretrained_model", "true")):
47-
url = f"{self.conf.get('pretrained_path', self.PRE_TRAINED_PATH)}/endoscopy_deid.pt"
47+
url = f"{self.conf.get('pretrained_path', self.PRE_TRAINED_PATH)}/endoscopy_inbody.pt"
4848
try:
4949
download_file(url, self.path[0])
5050
except:
@@ -56,14 +56,14 @@ def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **
5656

5757
# Others
5858
self.epistemic_enabled = bool(strtobool(conf.get("epistemic_enabled", "false")))
59-
self.epistemic_enabled = self.epistemic_enabled if self.conf.get("models") == "deid" else False
59+
self.epistemic_enabled = self.epistemic_enabled if self.conf.get("models") == "inbody" else False
6060
self.epistemic_max_samples = int(conf.get("epistemic_max_samples", "0"))
6161
self.epistemic_simulation_size = int(conf.get("epistemic_simulation_size", "5"))
6262

6363
logger.info(f"EPISTEMIC Enabled: {self.epistemic_enabled}; Samples: {self.epistemic_max_samples}")
6464

6565
def infer(self) -> Union[InferTask, Dict[str, InferTask]]:
66-
task: InferTask = lib.infers.DeID(
66+
task: InferTask = lib.infers.InBody(
6767
path=self.path,
6868
network=self.network,
6969
labels=self.labels,
@@ -73,13 +73,13 @@ def infer(self) -> Union[InferTask, Dict[str, InferTask]]:
7373

7474
def trainer(self) -> Optional[TrainTask]:
7575
output_dir = os.path.join(self.model_dir, self.name)
76-
task: TrainTask = lib.trainers.DeID(
76+
task: TrainTask = lib.trainers.InBody(
7777
model_dir=output_dir,
7878
network=self.network,
7979
load_path=self.path[0],
8080
publish_path=self.path[1],
8181
labels=self.labels,
82-
description="Train DeID Model",
82+
description="Train InBody/OutBody Classification Model",
8383
config={
8484
"max_epochs": 10,
8585
"train_batch_size": 1,
@@ -100,6 +100,6 @@ def scoring_method(self) -> Union[None, ScoringMethod, Dict[str, ScoringMethod]]
100100

101101
if self.epistemic_enabled:
102102
methods[f"{self.name}_epistemic"] = CVATRandomScoring(
103-
top_k=int(self.conf.get("epistemic_top_k", "10")), function="monailabel.endoscopy.deid"
103+
top_k=int(self.conf.get("epistemic_top_k", "10")), function="monailabel.endoscopy.inbody"
104104
)
105105
return methods

sample-apps/endoscopy/lib/infers/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
# limitations under the License.
1111

1212
from .deepedit import DeepEdit
13-
from .deid import DeID
13+
from .inbody import InBody
1414
from .tooltracking import ToolTracking

sample-apps/endoscopy/lib/infers/deid.py renamed to sample-apps/endoscopy/lib/infers/inbody.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
logger = logging.getLogger(__name__)
2525

2626

27-
class DeID(InferTask):
27+
class InBody(InferTask):
2828
"""
2929
This provides Inference Engine for pre-trained segmentation model for Tool Tracking.
3030
"""
@@ -36,7 +36,7 @@ def __init__(
3636
type=InferType.CLASSIFICATION,
3737
labels=None,
3838
dimension=2,
39-
description="A pre-trained semantic classification model for DeID",
39+
description="A pre-trained semantic classification model for InBody/OutBody",
4040
**kwargs,
4141
):
4242
super().__init__(

sample-apps/endoscopy/lib/trainers/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
# limitations under the License.
1111

1212
from .deepedit import DeepEdit
13-
from .deid import DeID
13+
from .inbody import InBody
1414
from .tooltracking import ToolTracking

sample-apps/endoscopy/lib/trainers/deid.py renamed to sample-apps/endoscopy/lib/trainers/inbody.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
logger = logging.getLogger(__name__)
3939

4040

41-
class DeID(BasicTrainTask):
41+
class InBody(BasicTrainTask):
4242
def __init__(
4343
self,
4444
model_dir,
4545
network,
4646
labels,
47-
description="Endoscopy Classification for DeID",
47+
description="Endoscopy Classification for InBody/OutBody",
4848
**kwargs,
4949
):
5050
self._network = network

sample-apps/endoscopy/main.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def main():
237237

238238
home = str(Path.home())
239239
studies = f"{home}/Dataset/Holoscan/tiny/images"
240-
studies = f"{home}/Dataset/picked/all"
240+
# studies = f"{home}/Dataset/picked/all"
241241
# studies = f"{home}/Dataset/Holoscan/flattened/images"
242242
# studies = f"{home}/Dataset/Holoscan/tiny_flat/images"
243243

@@ -248,9 +248,10 @@ def main():
248248
app_dir = os.path.dirname(__file__)
249249
studies = args.studies
250250

251-
app = MyApp(app_dir, studies, {"preload": "false", "models": "deid"})
251+
app = MyApp(app_dir, studies, {"preload": "true", "models": "deepedit"})
252252
logger.info(app.datastore().status())
253-
train_deid(app)
253+
for _ in range(3):
254+
infer_deepedit(app)
254255

255256

256257
def randamize_ds(train_datalist, val_datalist):
@@ -382,24 +383,24 @@ def infer_tooltracking(app):
382383
logger.info("All Done!")
383384

384385

385-
def infer_deid(app):
386+
def infer_inbody(app):
386387
import json
387388

388389
res = app.infer(
389390
request={
390-
"model": "deid",
391-
"image": "100",
391+
"model": "inbody",
392+
"image": "Video_8_2020_01_13_Video2_Trim_01-25_f10200",
392393
# "logging": "ERROR",
393394
}
394395
)
395396

396397
print(json.dumps(res["params"]["prediction"]))
397398

398399

399-
def train_deid(app):
400+
def train_inbody(app):
400401
res = app.train(
401402
request={
402-
"model": "deid",
403+
"model": "inbody",
403404
"max_epochs": 10,
404405
"dataset": "Dataset", # PersistentDataset, CacheDataset
405406
"train_batch_size": 1,

0 commit comments

Comments
 (0)