Skip to content

Commit

Permalink
add polyp det
Browse files Browse the repository at this point in the history
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
  • Loading branch information
yiheng-wang-nv committed Jan 9, 2025
1 parent 872d865 commit 55c2f96
Show file tree
Hide file tree
Showing 6 changed files with 560 additions and 0 deletions.
28 changes: 28 additions & 0 deletions applications/polyp_detection/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# syntax=docker/dockerfile:1

# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.


FROM nvcr.io/nvidia/clara-holoscan/holoscan:v2.7.0-dgpu

WORKDIR /colon_workspace

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# TODO: after having the final model weights, upload to some place instead
COPY rtdetrv2_timm_r50_nvimagenet_pretrained.onnx .
46 changes: 46 additions & 0 deletions applications/polyp_detection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Polyp Detection

## Build Docker

```Bash
docker build -t nvcr.io/nvidia/clara-holoscan/holoscan:v2.7.0-dgpu-polyp-det -f Dockerfile .
```

## Run Application

### Run Docker

Please mount the directory that contains `holohub/` into `/colon`. For example, my folder is under `/raid/colon_reproduce`.

```Bash
docker run --rm -it --gpus=all --ipc=host -p 8888:8888 -v /raid/colon_reproduce:/colon nvcr.io/nvidia/clara-holoscan/holoscan:v2.7.0-dgpu-polyp-det
```

### Generate TensorRT model

```Bash
trtexec --onnx=rtdetrv2_timm_r50_nvimagenet_pretrained.onnx --saveEngine=rt_detrv2_timm_r50_nvimagenet_pretrained_demo.trt \
--minShapes=images:1x3x640x640,orig_target_sizes:1x2 \
--optShapes=images:128x3x640x640,orig_target_sizes:128x2 \
--maxShapes=images:128x3x640x640,orig_target_sizes:128x2 \
--allowGPUFallback
```

### Grab example video

(todo) need to upload after license permisison

### Convert Video into GXF Entities

```Bash
apt-get update && apt-get install -y ffmpeg
git clone https://github.com/nvidia-holoscan/holoscan-sdk.git
ffmpeg -i <prepared video>.mp4 -pix_fmt rgb24 -f rawvideo pipe:1 | python holoscan-sdk/scripts/convert_video_to_gxf_entities.py --width 1164 --height 1034 --channels 3 --framerate 30 --directory /colon/holohub/data/polyp_detection/
```

### Run application

```Bash
cd /colon/holohub/applications/polyp_detection
python polyp_detection.py --data /colon/holohub/data/polyp_detection/
```
38 changes: 38 additions & 0 deletions applications/polyp_detection/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"application": {
"name": "Polyp detection",
"authors": [
{
"name": "Holoscan Team",
"affiliation": "NVIDIA"
}
],
"language": "Python",
"version": "1.0",
"changelog": {
"1.0": "Initial Release"
},
"holoscan_sdk": {
"minimum_required_version": "0.5.0",
"tested_versions": [
"0.5.0"
]
},
"platforms": [
"amd64",
"arm64"
],
"tags": [
"Colonoscopy",
"Detection"
],
"ranking": 1,
"dependencies": {
"libraries": []
},
"run": {
"command": "python3 polyp_detection.py --data <holohub_data_dir>/polyp_detection",
"workdir": "holohub_app_source"
}
}
}
Loading

0 comments on commit 55c2f96

Please sign in to comment.