Skip to content

Commit 509bd62

Browse files
authored
Update yolov8Transform.m
1 parent 96f06df commit 509bd62

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

+helper/yolov8Transform.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@
77
stride = [8,16,32];
88
batch = 1;
99

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);
1413

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
2519

2620
% Concat all Predictions
27-
predCat = cat(2,pred{:});
21+
predCat = cat(2,predAll{:});
2822

2923
% Split classes and boxes
3024
box = predCat(1:64,:,:);
3125
cls = predCat(65:end,:,:);
3226

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+
3333
box = helper.distributionFocalLoss(box);
3434
% Converting boxes to xywh format here
3535
box = helper.dist2bbox(box,anchorGrid);

0 commit comments

Comments
 (0)