未验证 提交 bb1ba033 编写于 作者: L LokeZhou 提交者: GitHub

To static (#7851)

* [TIPC] fcos add static train

* tinypose_128x96 add training static

* [TIPC] tinypose add static training

* disable maskrcnn static training
上级 203ad52b
...@@ -82,6 +82,66 @@ TO_STATIC_SPEC = { ...@@ -82,6 +82,66 @@ TO_STATIC_SPEC = {
'target2': paddle.static.InputSpec( 'target2': paddle.static.InputSpec(
name='target2', shape=[-1, 3, 86, -1, -1], dtype='float32'), name='target2', shape=[-1, 3, 86, -1, -1], dtype='float32'),
}], }],
'tinypose_128x96': [{
'center': paddle.static.InputSpec(
name='center', shape=[-1, 2], dtype='float32'),
'scale': paddle.static.InputSpec(
name='scale', shape=[-1, 2], dtype='float32'),
'im_id': paddle.static.InputSpec(
name='im_id', shape=[-1, 1], dtype='float32'),
'image': paddle.static.InputSpec(
name='image', shape=[-1, 3, 128, 96], dtype='float32'),
'score': paddle.static.InputSpec(
name='score', shape=[-1], dtype='float32'),
'rotate': paddle.static.InputSpec(
name='rotate', shape=[-1], dtype='float32'),
'target': paddle.static.InputSpec(
name='target', shape=[-1, 17, 32, 24], dtype='float32'),
'target_weight': paddle.static.InputSpec(
name='target_weight', shape=[-1, 17, 1], dtype='float32'),
}],
'fcos_r50_fpn_1x_coco': [{
'im_id': paddle.static.InputSpec(
name='im_id', shape=[-1, 1], dtype='float32'),
'curr_iter': paddle.static.InputSpec(
name='curr_iter', shape=[-1], dtype='float32'),
'image': paddle.static.InputSpec(
name='image', shape=[-1, 3, -1, -1], dtype='float32'),
'im_shape': paddle.static.InputSpec(
name='im_shape', shape=[-1, 2], dtype='float32'),
'scale_factor': paddle.static.InputSpec(
name='scale_factor', shape=[-1, 2], dtype='float32'),
'reg_target0': paddle.static.InputSpec(
name='reg_target0', shape=[-1, 160, 160, 4], dtype='float32'),
'labels0': paddle.static.InputSpec(
name='labels0', shape=[-1, 160, 160, 1], dtype='int32'),
'centerness0': paddle.static.InputSpec(
name='centerness0', shape=[-1, 160, 160, 1], dtype='float32'),
'reg_target1': paddle.static.InputSpec(
name='reg_target1', shape=[-1, 80, 80, 4], dtype='float32'),
'labels1': paddle.static.InputSpec(
name='labels1', shape=[-1, 80, 80, 1], dtype='int32'),
'centerness1': paddle.static.InputSpec(
name='centerness1', shape=[-1, 80, 80, 1], dtype='float32'),
'reg_target2': paddle.static.InputSpec(
name='reg_target2', shape=[-1, 40, 40, 4], dtype='float32'),
'labels2': paddle.static.InputSpec(
name='labels2', shape=[-1, 40, 40, 1], dtype='int32'),
'centerness2': paddle.static.InputSpec(
name='centerness2', shape=[-1, 40, 40, 1], dtype='float32'),
'reg_target3': paddle.static.InputSpec(
name='reg_target3', shape=[-1, 20, 20, 4], dtype='float32'),
'labels3': paddle.static.InputSpec(
name='labels3', shape=[-1, 20, 20, 1], dtype='int32'),
'centerness3': paddle.static.InputSpec(
name='centerness3', shape=[-1, 20, 20, 1], dtype='float32'),
'reg_target4': paddle.static.InputSpec(
name='reg_target4', shape=[-1, 10, 10, 4], dtype='float32'),
'labels4': paddle.static.InputSpec(
name='labels4', shape=[-1, 10, 10, 1], dtype='int32'),
'centerness4': paddle.static.InputSpec(
name='centerness4', shape=[-1, 10, 10, 1], dtype='float32'),
}],
} }
......
...@@ -69,12 +69,12 @@ class FCOSLoss(nn.Layer): ...@@ -69,12 +69,12 @@ class FCOSLoss(nn.Layer):
self.reg_weights = reg_weights self.reg_weights = reg_weights
self.quality = quality self.quality = quality
def __iou_loss(self, def _iou_loss(self,
pred, pred,
targets, targets,
positive_mask, positive_mask,
weights=None, weights=None,
return_iou=False): return_iou=False):
""" """
Calculate the loss for location prediction Calculate the loss for location prediction
Args: Args:
...@@ -216,7 +216,7 @@ class FCOSLoss(nn.Layer): ...@@ -216,7 +216,7 @@ class FCOSLoss(nn.Layer):
# 2. bboxes_reg: giou_loss # 2. bboxes_reg: giou_loss
mask_positive_float = paddle.squeeze(mask_positive_float, axis=-1) mask_positive_float = paddle.squeeze(mask_positive_float, axis=-1)
tag_center_flatten = paddle.squeeze(tag_center_flatten, axis=-1) tag_center_flatten = paddle.squeeze(tag_center_flatten, axis=-1)
reg_loss = self.__iou_loss( reg_loss = self._iou_loss(
bboxes_reg_flatten, bboxes_reg_flatten,
tag_bboxes_flatten, tag_bboxes_flatten,
mask_positive_float, mask_positive_float,
...@@ -233,7 +233,7 @@ class FCOSLoss(nn.Layer): ...@@ -233,7 +233,7 @@ class FCOSLoss(nn.Layer):
# 2. bboxes_reg: giou_loss # 2. bboxes_reg: giou_loss
mask_positive_float = paddle.squeeze(mask_positive_float, axis=-1) mask_positive_float = paddle.squeeze(mask_positive_float, axis=-1)
tag_center_flatten = paddle.squeeze(tag_center_flatten, axis=-1) tag_center_flatten = paddle.squeeze(tag_center_flatten, axis=-1)
reg_loss = self.__iou_loss( reg_loss = self._iou_loss(
bboxes_reg_flatten, bboxes_reg_flatten,
tag_bboxes_flatten, tag_bboxes_flatten,
mask_positive_float, mask_positive_float,
...@@ -243,7 +243,7 @@ class FCOSLoss(nn.Layer): ...@@ -243,7 +243,7 @@ class FCOSLoss(nn.Layer):
# 3. centerness: sigmoid_cross_entropy_with_logits_loss # 3. centerness: sigmoid_cross_entropy_with_logits_loss
centerness_flatten = paddle.squeeze(centerness_flatten, axis=-1) centerness_flatten = paddle.squeeze(centerness_flatten, axis=-1)
gt_ious = self.__iou_loss( gt_ious = self._iou_loss(
bboxes_reg_flatten, bboxes_reg_flatten,
tag_bboxes_flatten, tag_bboxes_flatten,
mask_positive_float, mask_positive_float,
......
...@@ -57,4 +57,6 @@ repeat:3 ...@@ -57,4 +57,6 @@ repeat:3
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:null flags:null
===========================infer_benchmark_params=========================== ===========================infer_benchmark_params===========================
numpy_infer_input:3x800x1344_2.npy numpy_infer_input:3x800x1344_2.npy
\ No newline at end of file ===========================to_static_train_benchmark_params===========================
to_static_train:--to_static
\ No newline at end of file
...@@ -57,4 +57,6 @@ repeat:1 ...@@ -57,4 +57,6 @@ repeat:1
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:null flags:null
===========================infer_benchmark_params=========================== ===========================infer_benchmark_params===========================
random_infer_input:[{float32,[3,128,96]}] random_infer_input:[{float32,[3,128,96]}]
\ No newline at end of file ===========================to_static_train_benchmark_params===========================
to_static_train:--to_static
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册