Repository URL to install this package:
|
Version:
5.0.6-1+cuda10.0 ▾
|
| .. |
| README.md |
| coco_labels.txt |
| data_processing.py |
| onnx_to_tensorrt.py |
| requirements.txt |
| yolov3_to_onnx.py |
This Python sample demonstrates how to run YOLOv3-608[^1] (with an input size of 608x608 pixels - in the following just referred to as YOLOv3) in TensorRT 5.0, using ONNX-TensorRT (https://github.com/onnx/onnx-tensorrt).
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
in onnx_to_tensorrt.py, followed by inference on a sample image. The predicted
bounding boxes are finally drawn to the original input image and saved to disk.
Note that this sample is not supported on Ubuntu 14.04 and older.
Additionally, the yolov3_to_onnx.py does not support Python 3.
python2 -m pip install -r requirements.txt from the root directory of this sample.python3 -m pip install -r requirements.txt from the root directory of this sample. python yolov3_to_onnx.py
When running above command for the first time, the output should look like
this:
Downloading from https://raw.githubusercontent.com/pjreddie/darknet/
f86901f6177dfc6116360a13cc06ab680e0c86b0/cfg/yolov3.cfg,
this may take a while...
100% [......................................................................
..........] 8342 / 8342
Downloading from https://pjreddie.com/media/files/yolov3.weights, this may
take a while...
100% [......................................................................
] 248007048 / 248007048
[...]
%106_convolutional = Conv[auto_pad = u'SAME_LOWER', dilations = [1, 1],
kernel_shape = [1, 1], strides = [1, 1]](%105_convolutional_lrelu,
%106_convolutional_conv_weights, %106_convolutional_conv_bias)
return %082_convolutional, %094_convolutional, %106_convolutional
}
python onnx_to_tensorrt.py
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.
[^1]: Redmon, Joseph, and Ali Farhadi. "Yolov3: An incremental improvement." arXiv preprint arXiv:1804.02767 (2018).