Skip to content

Commit 503f4ac

Browse files
Account for new gpuArray support in selectStrongestBboxes (#26)
Fixes #20. selectStrongestBbox got gpuArray support in MATLAB R2020b. Previously the gather was required if bboxes was gpuArray and needed to be on the cpu (strangely the scores didn't matter). In R2020b they need to be the same either both on the gpu or not, so we do a version check and adjust behaviour accordingly
1 parent 6823caa commit 503f4ac

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

code/mtcnn/+mtcnn/Detector.m

+6-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,12 @@
158158
bboxes = mtcnn.util.applyCorrection(bboxes, correction);
159159
bboxes(faceProbs < obj.ConfidenceThresholds(netIdx), :) = [];
160160
scores = faceProbs(faceProbs >= obj.ConfidenceThresholds(netIdx));
161-
if ~isempty(scores)
162-
[bboxes, scores, index] = selectStrongestBbox(gather(bboxes), scores, ...
161+
if ~isempty(scores)
162+
if verLessThan("matlab", "9.9")
163+
% < R2020b no gpuArray support for selectStrongestBbox
164+
[bboxes, scores] = gather(bboxes, scores);
165+
end
166+
[bboxes, scores, index] = selectStrongestBbox(bboxes, scores, ...
163167
"RatioType", "Min", ...
164168
"OverlapThreshold", obj.NmsThresholds(netIdx));
165169
if netIdx == 3

0 commit comments

Comments
 (0)