NGC | Catalog
CatalogModelsMONAI Endoscopic Inbody Classification

MONAI Endoscopic Inbody Classification

For downloads and more information, please view on a desktop device.
Logo for MONAI Endoscopic Inbody Classification


A pre-trained model for the endoscopic inbody classification task.



Latest Version



April 4, 2023


199.46 MB

Model Overview

A pre-trained model for the endoscopic inbody classification task and trained using the SEResNet50 structure, whose details can be found in [1]. All datasets are from private samples of Activ Surgical. Samples in training and validation dataset are from the same 4 videos, while test samples are from different two videos.

The PyTorch model and torchscript model are shared in google drive. Modify the bundle_root parameter specified in configs/train.json and configs/inference.json to reflect where models are downloaded. Expected directory path to place downloaded models is models/ under bundle_root.



The datasets used in this work were provided by Activ Surgical.

We've provided a link of 20 samples (10 in-body and 10 out-body) to show what this dataset looks like.


After downloading this dataset, python script in scripts folder named data_process can be used to generate label json files by running the command below and modifying datapath to path of unziped downloaded data. Generated label json files will be stored in label folder under the bundle path.

python scripts/ --datapath /path/to/data/root

By default, label path parameter in train.json and inference.json of this bundle is point to the generated label folder under bundle path. If you move these generated label files to another place, please modify the train_json, val_json and test_json parameters specified in configs/train.json and configs/inference.json to where these label files are.

The input label json should be a list made up by dicts which includes image and label keys. An example format is shown below.

        "label": 0
        "label": 0
        "label": 1
        "label": 0

Training configuration

The training as performed with the following:

  • GPU: At least 12GB of GPU memory
  • Actual Model Input: 256 x 256 x 3
  • Optimizer: Adam
  • Learning Rate: 1e-3


A three channel video frame


Two Channels

  • Label 0: in body
  • Label 1: out body


Accuracy was used for evaluating the performance of the model. This model achieves an accuracy score of 0.98

Training Loss

A graph showing the training loss over 25 epochs.

Validation Accuracy

A graph showing the validation accuracy over 25 epochs.

MONAI Bundle Commands

In addition to the Pythonic APIs, a few command line interfaces (CLI) are provided to interact with the bundle. The CLI supports flexible use cases, such as overriding configs at runtime and predefining arguments in a file.

For more details usage instructions, visit the MONAI Bundle Configuration Page.

Execute training:
python -m monai.bundle run training \
    --meta_file configs/metadata.json \
    --config_file configs/train.json \
    --logging_file configs/logging.conf
Override the train config to execute multi-GPU training:
torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run training \
    --meta_file configs/metadata.json \
    --config_file "['configs/train.json','configs/multi_gpu_train.json']" \
    --logging_file configs/logging.conf

Please note that the distributed training-related options depend on the actual running environment; thus, users may need to remove --standalone, modify --nnodes, or do some other necessary changes according to the machine used. For more details, please refer to pytorch's official tutorial.

In addition, if using the 20 samples example dataset, the preprocessing script will divide the samples to 16 training samples, 2 validation samples and 2 test samples. However, pytorch multi-gpu training requires number of samples in dataloader larger than gpu numbers. Therefore, please use no more than 2 gpus to run this bundle if using the 20 samples example dataset.

Override the train config to execute evaluation with the trained model:
python -m monai.bundle run evaluating \
    --meta_file configs/metadata.json \
    --config_file "['configs/train.json','configs/evaluate.json']" \
    --logging_file configs/logging.conf
Execute inference:
python -m monai.bundle run evaluating \
    --meta_file configs/metadata.json \
    --config_file configs/inference.json \
    --logging_file configs/logging.conf

The classification result of every images in test.json will be printed to the screen.

Export checkpoint to TorchScript file:
python -m monai.bundle ckpt_export network_def \
    --filepath models/model.ts \
    --ckpt_file models/ \
    --meta_file configs/metadata.json \
    --config_file configs/inference.json


[1] J. Hu, L. Shen and G. Sun, Squeeze-and-Excitation Networks, 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018, pp. 7132-7141.


This training and inference pipeline was developed by NVIDIA. It is based on a model developed by NVIDIA researchers. This software has not been cleared or approved by FDA or any regulatory agency. MONAI pre-trained models are for developmental purposes only and cannot be used directly for clinical procedures.


Copyright (c) MONAI Consortium

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.