You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
why yolov8 uses torch.zeros(1, ch, s, s) as input to forward pass to calculate model stride ? can someone explain me will different task will have different stride
#4492
m = self.model[-1] # Detect()
if isinstance(m, (Detect, Segment, Pose)):
s = 256 # 2x min stride
m.inplace = self.inplace
forward = lambda x: self.forward(x)[0] if isinstance(m, (Segment, Pose)) else self.forward(x)
m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward
self.stride = m.stride
m.bias_init() # only run once
else:
self.stride = torch.Tensor([32]) # default stride for i.e. RTDETR
The coord box edge is encoded in DFL form with reg_max=16 if I'm right. However, I still don't know whether the label box is scaled by stride to 3 different heads or not to calculate the loss function. Can you explain this, please?
The label box is indeed scaled by the stride for each detection head to calculate the loss function accurately. This ensures alignment between the feature map and the original image dimensions.
Assume that I have a label box x_center, y_center, w, h in relative coordinates. I read that reg_max=16 means there are 16 bins for the probability offset of an anchor. How model set the label for DFL layer of a head to calculate DFLoss? Can you explain more detail, please? Thank you very much.
The label for the DFL layer is set by discretizing the continuous offset into reg_max=16 bins, representing the probability distribution of the offset from the anchor. This helps the model learn precise localization by predicting the most likely bin for each coordinate.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
reference task.py file:
Build strides
m = self.model[-1] # Detect()
if isinstance(m, (Detect, Segment, Pose)):
s = 256 # 2x min stride
m.inplace = self.inplace
forward = lambda x: self.forward(x)[0] if isinstance(m, (Segment, Pose)) else self.forward(x)
m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward
self.stride = m.stride
m.bias_init() # only run once
else:
self.stride = torch.Tensor([32]) # default stride for i.e. RTDETR
Beta Was this translation helpful? Give feedback.
All reactions