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

* Add multi-label function for yolov5

* Update README.md

Update doc

* Update fastdeploy_runtime.cc

fix variable option.trt_max_shape wrong name

* Update runtime_option.md

Update resnet model dynamic shape setting name from images to x

* Fix bug when inference result boxes are empty

* Delete detection.py
This commit is contained in:
huangjianhui
2022-07-19 19:42:44 +08:00
committed by GitHub
parent 1fa14712ad
commit 39aca6787a
2 changed files with 10 additions and 1 deletions

View File

@@ -202,6 +202,11 @@ bool YOLOv5::Postprocess(
result->scores.push_back(confidence); result->scores.push_back(confidence);
} }
} }
if (result->boxes.size() == 0) {
return true;
}
utils::NMS(result, nms_iou_threshold); utils::NMS(result, nms_iou_threshold);
// scale the boxes to the origin image shape // scale the boxes to the origin image shape

View File

@@ -68,7 +68,11 @@ void MergeSort(DetectionResult* result, size_t low, size_t high) {
void SortDetectionResult(DetectionResult* result) { void SortDetectionResult(DetectionResult* result) {
size_t low = 0; 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); MergeSort(result, low, high);
} }