From 5792f346dd7e6c5eec48698e09c3828d0ed16f64 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 18 Oct 2019 14:59:38 +0800 Subject: [PATCH] remove actual_shape in resize_nearest and use_progam_cache in yolov3/infer.py (#3617) * remove actual_shape * add fpn fix --- ppdet/modeling/anchor_heads/yolo_head.py | 12 +----------- ppdet/modeling/backbones/fpn.py | 7 +------ 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/ppdet/modeling/anchor_heads/yolo_head.py b/ppdet/modeling/anchor_heads/yolo_head.py index 19829233f..7e756f267 100644 --- a/ppdet/modeling/anchor_heads/yolo_head.py +++ b/ppdet/modeling/anchor_heads/yolo_head.py @@ -148,18 +148,8 @@ class YOLOv3Head(object): return route, tip def _upsample(self, input, scale=2, name=None): - # get dynamic upsample output shape - shape_nchw = fluid.layers.shape(input) - shape_hw = fluid.layers.slice( - shape_nchw, axes=[0], starts=[2], ends=[4]) - shape_hw.stop_gradient = True - in_shape = fluid.layers.cast(shape_hw, dtype='int32') - out_shape = in_shape * scale - out_shape.stop_gradient = True - - # reisze by actual_shape out = fluid.layers.resize_nearest( - input=input, scale=scale, actual_shape=out_shape, name=name) + input=input, scale=float(scale), name=name) return out def _parse_anchors(self, anchors): diff --git a/ppdet/modeling/backbones/fpn.py b/ppdet/modeling/backbones/fpn.py index 762df42d1..9bd491a66 100644 --- a/ppdet/modeling/backbones/fpn.py +++ b/ppdet/modeling/backbones/fpn.py @@ -87,13 +87,8 @@ class FPN(object): learning_rate=2., regularizer=L2Decay(0.)), name=lateral_name) - shape = fluid.layers.shape(upper_output) - shape_hw = fluid.layers.slice(shape, axes=[0], starts=[2], ends=[4]) - out_shape_ = shape_hw * 2 - out_shape = fluid.layers.cast(out_shape_, dtype='int32') - out_shape.stop_gradient = True topdown = fluid.layers.resize_nearest( - upper_output, scale=2., actual_shape=out_shape, name=topdown_name) + upper_output, scale=2., name=topdown_name) return lateral + topdown -- GitLab