Skip to content

Commit

Permalink
obb head separate outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
lsutardja authored Feb 6, 2025
1 parent b350130 commit 15e2fc9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ultralytics/nn/modules/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ def __init__(self, nc=80, ne=1, ch=()):
def forward(self, x):
"""Concatenates and returns predicted bounding boxes and class probabilities."""
bs = x[0].shape[0] # batch size

if self.separate_outputs and self.export:
outputs = []
for i in range(self.nl):
angle_logit = self.cv4[i](x[i]).view(bs, self.ne, -1)
outputs.append(angle_logit)

outputs.extend(Detect.forward(self, x))
return outputs

angle = torch.cat([self.cv4[i](x[i]).view(bs, self.ne, -1) for i in range(self.nl)], 2) # OBB theta logits
# NOTE: set `angle` as an attribute so that `decode_bboxes` could use it.
angle = (angle.sigmoid() - 0.25) * math.pi # [-pi/4, 3pi/4]
Expand Down

0 comments on commit 15e2fc9

Please sign in to comment.