到 ONNX model zoo 找尋 Tiny YOLOv2 model 下載 tinyyolov2-8.onnx (Opset version 8)
Tiny YOLOv2 解說
Input Shape (1x3x416x416)
Output Shape (1x125x13x13)
125 分成 5 個 BBox, 每個有 25 cells(32 bits)
前 5 個是 bounding box, 後 20 是 class probabilities
$ git clone https://github.com/thatbrguy/Deep-Stream-ONNX.git
$ cd Deep-Stream-ONNX
$ mv ~/Downloads/tinyyolov2-8.onnx .
下載 sample.tar.gz 並解壓縮
$ vi config/config_infer_custom_yolo.txt
onnx-file=../tinyyolov2-8.onnx
parse-bbox-func-name=NvDsInferParseCustomYoloV2Tiny
custom-lib-path=../custom_bbox_parser/libnvdsinfer_custom_bbox_tiny_yolo.so
$ vi custom_bbox_parser/Makefile
SRCFILES:=nvdsparsebbox_tiny_yolo.cpp
TARGET_LIB:=libnvdsinfer_custom_bbox_tiny_yolo.so
DEEPSTREAM_PATH:=/opt/nvidia/deepstream/deepstream-5.0
$ vi custom_bbox_parser/nvdsparsebbox_tiny_yolo.cpp
//assert (layer.dims.numDims == 3); 修改
assert (layer.inferDims.numDims == 3);
extern "C" bool NvDsInferParseCustomYoloV2Tiny(
std::vector<NvDsInferLayerInfo> const& outputLayersInfo,
NvDsInferNetworkInfo const& networkInfo,
NvDsInferParseDetectionParams const& detectionParams,
std::vector<NvDsInferParseObjectInfo>& objectList);
outputLayersInfo: 為 ONNX 的輸出, outputLayersInfo[0].buffer
networkInfo: 為 ONNX 模型的資訊
detectionParams: 有 config params 的資料,如 numClassesConfigured
objectList: 是我們要產生的輸出
測試
$ deepstream-app -c config/deepstream_app_custom_yolo.txt
沒有留言:
張貼留言