Skip to content

Commit

Permalink
Fix YOLOv8 C++ ONNXRuntime transpose op (ultralytics#15779)
Browse files Browse the repository at this point in the history
Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
memorylorry and glenn-jocher authored Aug 24, 2024
1 parent e2b04dc commit dc15242
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/YOLOv8-ONNXRuntime-CPP/inference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,27 @@ char* YOLO_V8::TensorProcess(clock_t& starttime_1, cv::Mat& iImg, N& blob, std::
case YOLO_DETECT_V8:
case YOLO_DETECT_V8_HALF:
{
int strideNum = outputNodeDims[1];//8400
int signalResultNum = outputNodeDims[2];//84
int signalResultNum = outputNodeDims[1];//84
int strideNum = outputNodeDims[2];//8400
std::vector<int> class_ids;
std::vector<float> confidences;
std::vector<cv::Rect> boxes;
cv::Mat rawData;
if (modelType == YOLO_DETECT_V8)
{
// FP32
rawData = cv::Mat(strideNum, signalResultNum, CV_32F, output);
rawData = cv::Mat(signalResultNum, strideNum, CV_32F, output);
}
else
{
// FP16
rawData = cv::Mat(strideNum, signalResultNum, CV_16F, output);
rawData = cv::Mat(signalResultNum, strideNum, CV_16F, output);
rawData.convertTo(rawData, CV_32F);
}
//Note:
//ultralytics add transpose operator to the output of yolov8 model.which make yolov8/v5/v7 has same shape
//https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt
//rowData = rowData.t();
rawData = rawData.t();

float* data = (float*)rawData.data;

Expand Down

0 comments on commit dc15242

Please sign in to comment.