Home

Awesome

New tensorrt package, easy to integrate many tasks

For the Yolo-Demo

Description

Inference flow of trt

step1 Compile the model, e.g.

trtexec --onnx=yolov5s.onnx --saveEngine=yolov5s.engine

step2: Use infer inference

model = trt::load("yolov5s.engine");
... preprocess ...

// Configure the dynamic batch size.
auto dims = model->static_dims();
dims[0] = batch;
model->set_run_dims(dims);
model->forward({input_device, output_device}, stream);

... postprocess ...

step2: Use yolo inference

cv::Mat image = cv::imread("image.jpg");
auto model = yolo::load("yolov5s.engine");
auto objs = model->forward(yolo::Image(image.data, image.cols, image.rows));
// use objs to draw to image. 

Use of CPM (wrapping the inference as producer-consumer)

cpm::Instance<yolo::BoxArray, yolo::Image, yolo::Infer> cpmi;
cpmi.start([]{
    return yolo::load("yolov5s.engine", yolo::Type::V5);
}, batch);

auto result_futures = cpmi.commits(images);
for(auto& fut : result_futures){
    auto objs = fut.get();
    ... process ...
}

Reference