This repository contains the code for the 3rd place solution in the DAC-SDC-2024 GPU Track.
You can find everything you need in GPU-Track/SKKU_IRIS_scripts
This project heavily based on Ultralytics. Our training and export codes are build on it. You need to install ultralytics
pip install ultralytics
or just use shell script file install.sh
for conda environment settings.
bash install.sh
This file generate the instance segmentation data as the form of ultralytics
. In this challenge, our strategy is treating the bounding box as the instance segmentation polygon. Therefore, this script converts all bounding boxes into instance segmentation polygons.
This script trains a YOLOv8 segmentation model on a GPU.
This script exports a pretrained YOLOv8 segmentation pytorch
model to ONNX
model
This file contains all the pre-/post-processing and TensorRT engine execution behaviors.
-
Pre-process:
- Resize the source image to fit the model input size.
- Convert data types.
- Copy data from host (CPU) to device (CUDA).
-
Post-process:
- Execute non-maximum suppression and operations for mask generation using the TensorRT engine (
IRIS_post.trt
). - Crop masks.
- Upscale masks.
- Apply thresholds to masks.
- Rescale masks and bounding boxes.
- Execute non-maximum suppression and operations for mask generation using the TensorRT engine (
-
TensorRTEngine:
- Run the neural network using the TensorRT engine (
IRIS.trt
).
- Run the neural network using the TensorRT engine (
This script generate TensorRT engines (*.trt
, *_post.trt
) based on ONNX
model file.
This is the TensorRT engine file for the neural network model, based on a custom YOLOv8n-seg model.
This TensorRT engine file implements parts of the post-processing, including:
- Non-maximum suppression.
- Sigmoid activation and matrix multiplication for mask generation.
To run the inference code on Jetson Nano, follow these steps:
-
Prerequisites:
- Ensure you have the required dependencies installed, including TensorRT, pycuda, numpy, opencv-python, and tqdm.
- We recommend you to use JetPack SDK 4.6.1
- You can install rest of them using pip:
pip install pycuda tqdm
-
Setup:
- Place your images in a directory named
images
located in the parent directory of the project. Ensure the images are in.jpg
format.
- Place your images in a directory named
-
Running the Code:
-
You can run the script by providing the path to the TensorRT engine file (
IRIS.trt
). If no engine file path is provided, it defaults toIRIS.trt
in the current directory.python iris_utils_v6.py [path_to_engine_file]
-
Example:
python iris_utils_v6.py IRIS.trt
or you can run the script using
dac_sdc.ipynb
notebook
-
-
Output:
- The script processes the images and generates a result dictionary containing the processed output for each image. The processing includes pre-processing the images, running the TensorRT engine, and post-processing the outputs.
-
Profiling:
- The script includes time profiling for different stages (pre-processing, engine execution, and post-processing) to help analyze performance.
- For this functionality, you need to install
line_profiler
pip install line_profiler
- Then you can run the script with an environment variable
LINE_PROFILE=1
LINE_PROFILE=1 python iris_utils_v6.py IRIS.trt