Skip to content

Commit

Permalink
fix yolov8 head export
Browse files Browse the repository at this point in the history
  • Loading branch information
nemonameless committed May 18, 2023
1 parent 718907c commit 57b6178
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ppdet/modeling/heads/yolov8_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import paddle.nn.functional as F
from paddle import ParamAttr
from paddle.regularizer import L2Decay
from ..initializer import constant_
from ppdet.core.workspace import register

from ..bbox_utils import batch_distance2bbox
Expand Down Expand Up @@ -119,17 +120,18 @@ def __init__(self,
bias_attr=ParamAttr(regularizer=L2Decay(0.0))),
]))
self.proj = paddle.arange(self.reg_max).astype('float32')
#self._init_bias() ?
self._initialize_biases()

@classmethod
def from_config(cls, cfg, input_shape):
return {'in_channels': [i.channels for i in input_shape], }

def _init_bias(self):
def _initialize_biases(self):
for a, b, s in zip(self.conv_reg, self.conv_cls, self.fpn_strides):
a[-1].bias.set_value(1.0) # box
b[-1].bias[:self.num_classes] = math.log(5 / self.num_classes /
(640 / s)**2)
constant_(a[-1].weight)
constant_(a[-1].bias, 1.0)
constant_(b[-1].weight)
constant_(b[-1].bias, math.log(5 / self.num_classes / (640 / s)**2))

def forward(self, feats, targets=None):
if self.training:
Expand Down

0 comments on commit 57b6178

Please sign in to comment.