|
7 | 7 | stride = [8,16,32];
|
8 | 8 | batch = 1;
|
9 | 9 |
|
10 |
| -% Extract feature maps from Matlab model |
11 |
| -% Apply this if dlarray output |
12 |
| -predictions = cellfun(@extractdata,predictions,'UniformOutput',false); |
13 |
| -predictions = cellfun(@gather,predictions,'UniformOutput',false); |
| 10 | +pred = cell(3,1); |
| 11 | +predPermute = cell(3,1); |
| 12 | +predAll = cell(3,1); |
14 | 13 |
|
15 |
| -% Compute anchor grid and stride |
16 |
| -[anchorGrid, stride] = helper.make_anchors(predictions, stride); |
17 |
| -% anchor grid and stride transposed |
18 |
| -anchorGrid = anchorGrid'; |
19 |
| -stride = stride'; |
20 |
| - |
21 |
| -% Reshape predictions from model output |
22 |
| -pred = cellfun(@(p){permute(p,[2,1,3,4])}, predictions, 'UniformOutput',true); |
23 |
| -pred = cellfun(@(p){reshape(p,[],outputsPerAnchor, batch)}, pred, 'UniformOutput',true); |
24 |
| -pred = cellfun(@(p){permute(p,[2,1,3,4])}, pred, 'UniformOutput',true); |
| 14 | +for i = 1:size(predictions,1) |
| 15 | + pred{i,1} = permute(predictions{i,1},[2,1,3,4]); |
| 16 | + predPermute{i,1} = reshape(pred{i,1},[],outputsPerAnchor,batch); |
| 17 | + predAll{i,1} = permute(predPermute{i,1},[2,1,3,4]); |
| 18 | +end |
25 | 19 |
|
26 | 20 | % Concat all Predictions
|
27 |
| -predCat = cat(2,pred{:}); |
| 21 | +predCat = cat(2,predAll{:}); |
28 | 22 |
|
29 | 23 | % Split classes and boxes
|
30 | 24 | box = predCat(1:64,:,:);
|
31 | 25 | cls = predCat(65:end,:,:);
|
32 | 26 |
|
| 27 | +% Compute anchor grid and stride |
| 28 | +[anchorGrid, stride] = helper.make_anchors(predictions, stride); |
| 29 | +% anchor grid and stride transposed |
| 30 | +anchorGrid = anchorGrid'; |
| 31 | +stride = stride'; |
| 32 | + |
33 | 33 | box = helper.distributionFocalLoss(box);
|
34 | 34 | % Converting boxes to xywh format here
|
35 | 35 | box = helper.dist2bbox(box,anchorGrid);
|
|
0 commit comments