[TensorRT] Object Detection With The ONNX TensorRT Backend In Python
TensorRT 샘플인 yolov3_onnx 를 돌려보았다.
샘플 파일 위치 : .........../TensorRT-5.0.2.6/samples/python/yolov3_onnx
이 샘플은 python 3 와 Ubuntu14.04 이전 버전을 지원하지 않음 주의
1. TensorRT 설치
2019/04/09 - [Deep Learning/TensorRT] - [TensorRT] TensorRT 설치
2. Onnx 설치 (필자는 루트환경에 설치했으므로 sudo 를 사용)
python2 -m pip install onnx==1.2.2
3. requirements.txt 설치
python2 -m pip install -r requirements.txt
4. yolov3_to_onnx.py 코드 실행 (한번만 실행)
python2 yolov3_to_onnx.py
5. onnx_to_tensorrt.py 코드 실행
python2 onnx_to_tensorrt.py
6. 생성된 이미지 확인
Doing this for the first time should produce the following output:
```
Downloading from https://github.com/pjreddie/darknet/raw/f86901f6177dfc6116
360a13cc06ab680e0c86b0/data/dog.jpg, this may take a while...
100% [.....................................................................
.......] 163759 / 163759
Building an engine from file yolov3.onnx, this may take a while...
Running inference on image dog.jpg...
Saved image with bounding boxes of detected objects to dog_bboxes.jpg.
```
아래는 원문이다.
22. Object Detection With The ONNX TensorRT Backend In Python
What Does This Sample Do?
This sample, yolov3_onnx, implements a full ONNX-based pipeline for performing inference with the YOLOv3 network, with an input size of 608 x 608 pixels, including pre and post-processing. This sample is based on the YOLOv3-608 paper.
First, the original YOLOv3 specification from the paper is converted to the Open Neural Network Exchange (ONNX) format in yolov3_to_onnx.py (only has to be done once).
Second, this ONNX representation of YOLOv3 is used to build a TensorRT engine, followed by inference on a sample image in onnx_to_tensorrt.py. The predicted bounding boxes are finally drawn to the original input image and saved to disk.
After inference, post-processing including bounding-box clustering is applied. The resulting bounding boxes are eventually drawn to a new image file and stored on disk for inspection.
Note: This sample is not supported on Ubuntu 14.04 and older. Additionally, the yolov3_to_onnx.py script does not support Python 3.
Where Is This Sample Located?
This sample is installed in the /usr/src/tensorrt/samples/python/yolov3_onnx directory.
Getting Started:
Refer to the /usr/src/tensorrt/samples/python/yolov3_onnx/README.md file for detailed information about how this sample works, sample code, and step-by-step instructions on how to run and verify its output.
참고자료 : https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html
'AI Development > TensorRT' 카테고리의 다른 글
[TensorRT] TensorRT를 이용한 ResNet 예제 (0) | 2019.04.12 |
---|---|
[TensorRT] TensorRT support Python2.7, 3.5 (0) | 2019.04.12 |
[TensorRT] Docker Container를 이용한 TensorRT 설치 (0) | 2019.04.10 |
[TensorRT] TensorRT 5.0.2 Compatibility (0) | 2019.04.09 |
[TensorRT] TensorRT 설치 (0) | 2019.04.09 |