Update detector.c

Fix an issue with YOLO crash if number of validated examples less then 4 due to trying to access to unaddressable memory path[i+t], when i+t > nthreads.
This commit is contained in:
Dmitrivm 2017-11-17 12:38:17 +03:00 committed by GitHub
parent 16686cec57
commit 7ee9ebda1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -290,6 +290,12 @@ void validate_detector_flip(char *datacfg, char *cfgfile, char *weightfile, char
float nms = .45;
int nthreads = 4;
// fix an issue with YOLO crash if number of validated examples less then 4
// due to trying to access to unaddressable memory path[i+t], when i+t > nthreads
if (m < 4) {
nthreads = m;
}
image *val = calloc(nthreads, sizeof(image));
image *val_resized = calloc(nthreads, sizeof(image));
image *buf = calloc(nthreads, sizeof(image));
@ -423,6 +429,12 @@ void validate_detector(char *datacfg, char *cfgfile, char *weightfile, char *out
float nms = .45;
int nthreads = 4;
// fix an issue with YOLO crash if number of validated examples less then 4
// due to trying to access to unaddressable memory path[i+t], when i+t > nthreads
if (m < 4) {
nthreads = m;
}
image *val = calloc(nthreads, sizeof(image));
image *val_resized = calloc(nthreads, sizeof(image));
image *buf = calloc(nthreads, sizeof(image));