未验证 提交 1719561d 编写于 作者: S shangliang Xu 提交者: GitHub

[PPYOLOE] alter eval_input_size (#5569) (#5610)

上级 ab5b0151
......@@ -28,7 +28,6 @@ PPYOLOEHead:
grid_cell_offset: 0.5
static_assigner_epoch: 100
use_varifocal_loss: True
eval_input_size: [640, 640]
loss_weight: {class: 1.0, iou: 2.5, dfl: 0.5}
static_assigner:
name: ATSSAssigner
......
worker_num: 4
eval_height: &eval_height 640
eval_width: &eval_width 640
eval_size: &eval_size [*eval_height, *eval_width]
TrainReader:
sample_transforms:
- Decode: {}
......@@ -20,17 +24,17 @@ TrainReader:
EvalReader:
sample_transforms:
- Decode: {}
- Resize: {target_size: [640, 640], keep_ratio: False, interp: 2}
- Resize: {target_size: *eval_size, keep_ratio: False, interp: 2}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
- Permute: {}
batch_size: 2
TestReader:
inputs_def:
image_shape: [3, 640, 640]
image_shape: [3, *eval_height, *eval_width]
sample_transforms:
- Decode: {}
- Resize: {target_size: [640, 640], keep_ratio: False, interp: 2}
- Resize: {target_size: *eval_size, keep_ratio: False, interp: 2}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
- Permute: {}
batch_size: 1
......@@ -45,7 +45,7 @@ class ESEAttn(nn.Layer):
@register
class PPYOLOEHead(nn.Layer):
__shared__ = ['num_classes', 'trt', 'exclude_nms']
__shared__ = ['num_classes', 'eval_size', 'trt', 'exclude_nms']
__inject__ = ['static_assigner', 'assigner', 'nms']
def __init__(self,
......@@ -61,7 +61,7 @@ class PPYOLOEHead(nn.Layer):
static_assigner='ATSSAssigner',
assigner='TaskAlignedAssigner',
nms='MultiClassNMS',
eval_input_size=[],
eval_size=None,
loss_weight={
'class': 1.0,
'iou': 2.5,
......@@ -80,7 +80,7 @@ class PPYOLOEHead(nn.Layer):
self.iou_loss = GIoULoss()
self.loss_weight = loss_weight
self.use_varifocal_loss = use_varifocal_loss
self.eval_input_size = eval_input_size
self.eval_size = eval_size
self.static_assigner_epoch = static_assigner_epoch
self.static_assigner = static_assigner
......@@ -127,7 +127,7 @@ class PPYOLOEHead(nn.Layer):
self.proj.reshape([1, self.reg_max + 1, 1, 1]))
self.proj_conv.weight.stop_gradient = True
if self.eval_input_size:
if self.eval_size:
anchor_points, stride_tensor = self._generate_anchors()
self.register_buffer('anchor_points', anchor_points)
self.register_buffer('stride_tensor', stride_tensor)
......@@ -164,8 +164,8 @@ class PPYOLOEHead(nn.Layer):
if feats is not None:
_, _, h, w = feats[i].shape
else:
h = int(self.eval_input_size[0] / stride)
w = int(self.eval_input_size[1] / stride)
h = int(self.eval_size[0] / stride)
w = int(self.eval_size[1] / stride)
shift_x = paddle.arange(end=w) + self.grid_cell_offset
shift_y = paddle.arange(end=h) + self.grid_cell_offset
shift_y, shift_x = paddle.meshgrid(shift_y, shift_x)
......@@ -181,7 +181,7 @@ class PPYOLOEHead(nn.Layer):
return anchor_points, stride_tensor
def forward_eval(self, feats):
if self.eval_input_size:
if self.eval_size:
anchor_points, stride_tensor = self.anchor_points, self.stride_tensor
else:
anchor_points, stride_tensor = self._generate_anchors(feats)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册