|
1 | | -function [bboxes, scores] = proposeRegions(im, scale, threshold, weightsOrNet) |
| 1 | +function [bboxes, scores] = proposeRegions(im, scale, threshold, networkStrategy) |
2 | 2 | % proposeRegions Generate region proposals at a given scale. |
3 | 3 | % |
4 | 4 | % Args: |
|
13 | 13 |
|
14 | 14 | % Copyright 2019 The MathWorks, Inc. |
15 | 15 |
|
16 | | - useDagNet = isa(weightsOrNet, "DAGNetwork"); |
17 | | - if isa(im, "gpuArray") |
18 | | - imClass = classUnderlying(im); |
19 | | - else |
20 | | - imClass = class(im); |
21 | | - end |
22 | | - assert(imClass == "single", "mtcnn:proposeRegions:wrongImageType", ... |
23 | | - "Input image should be a single scale -1 to 1"); |
24 | 16 |
|
25 | 17 | % Stride of the proposal network |
26 | 18 | stride = 2; |
27 | 19 | % Field of view of the proposal network in pixels |
28 | 20 | pnetSize = 12; |
29 | 21 |
|
30 | 22 | im = imresize(im, 1/scale); |
31 | | - |
32 | | - if useDagNet |
33 | | - % need to use activations as we don't know what size it will be |
34 | | - result = weightsOrNet.activations(im, "concat"); |
35 | | - probability = gather(result(:,:,1:2,:)); |
36 | | - correction = gather(result(:,:,3:end,:)); |
37 | | - else |
38 | | - im = dlarray(im, "SSCB"); |
39 | | - [probability, correction] = mtcnn.pnet(im, weightsOrNet); |
40 | | - probability = extractdata(gather(probability)); |
41 | | - correction = extractdata(gather(correction)); |
42 | | - end |
43 | | - |
| 23 | + |
| 24 | + [probability, correction] = networkStrategy.applyPNet(im); |
44 | 25 |
|
45 | 26 | faces = probability(:,:,2) > threshold; |
46 | 27 | if sum(faces, 'all') == 0 |
|
0 commit comments