Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug while the inference result is empty with YOLOv5 #29

Merged
merged 9 commits into from
Jul 19, 2022
5 changes: 5 additions & 0 deletions fastdeploy/vision/ultralytics/yolov5.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ bool YOLOv5::Postprocess(
result->scores.push_back(confidence);
}
}

if (result->boxes.size() == 0) {
return true;
}

utils::NMS(result, nms_iou_threshold);

// scale the boxes to the origin image shape
Expand Down
6 changes: 5 additions & 1 deletion fastdeploy/vision/utils/sort_det_res.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ void MergeSort(DetectionResult* result, size_t low, size_t high) {

void SortDetectionResult(DetectionResult* result) {
size_t low = 0;
size_t high = result->scores.size() - 1;
size_t high = result->scores.size();
if (high == 0) {
return;
}
high = high - 1;
MergeSort(result, low, high);
}

Expand Down