in models/01_YoloV5/01_Pytorch/processing_cpp/src/processor.cc [93:113]
std::tuple<vecf,vecf,vecf> Processor::getDetections(const vecf& predictions, float iou_threshold ) {
// organize the outputs into bboxes, scores and class ids (cids)
// the last dim has: 5 + 80
// bboxes=0-3
vecf bboxes = xywh2xyxy(xt::strided_view(predictions, {xt::ellipsis(), xt::range(0,4)}));
// view=5-
auto view = xt::view(predictions, xt::all(), xt::range(5, xt::placeholders::_));
vecf scores = xt::amax( view, {1} );
vecf cids = xt::argmax( view, -1);
std::tuple<vecf,vecf,vecf> detections(bboxes, scores, cids);
// invoke Non maximum suppression
nms(detections, iou_threshold);
vecf& selectedBboxes = xt::get<0>(detections);
// normalize all bboxes
xt::view(selectedBboxes, xt::all(), 0) /= width; // x1
xt::view(selectedBboxes, xt::all(), 1) /= height; // y1
xt::view(selectedBboxes, xt::all(), 2) /= width; // x2
xt::view(selectedBboxes, xt::all(), 3) /= height; // y2
selectedBboxes = xt::clip(selectedBboxes, 0.0, 1.0);
return detections;
}