diff --git a/PaddleCV/PaddleDetection/ppdet/modeling/anchor_heads/yolo_head.py b/PaddleCV/PaddleDetection/ppdet/modeling/anchor_heads/yolo_head.py index 19829233f4833669131ecaa3fb13002d2062e93e..7e756f267762827b3666e8143dce9a695fc526e2 100644 --- a/PaddleCV/PaddleDetection/ppdet/modeling/anchor_heads/yolo_head.py +++ b/PaddleCV/PaddleDetection/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/PaddleCV/PaddleDetection/ppdet/modeling/backbones/fpn.py b/PaddleCV/PaddleDetection/ppdet/modeling/backbones/fpn.py index 823f7c2857622718281e7dda23f64144aeae2102..840c8536106b162c1be1bdad402195d7d7a73653 100644 --- a/PaddleCV/PaddleDetection/ppdet/modeling/backbones/fpn.py +++ b/PaddleCV/PaddleDetection/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 diff --git a/PaddleCV/yolov3/README.md b/PaddleCV/yolov3/README.md index d6ddf71ca2ad8a16e3198f3627e4a19677e7e927..7f71ca9202da1565e90f1e60102b10c04e4aff04 100644 --- a/PaddleCV/yolov3/README.md +++ b/PaddleCV/yolov3/README.md @@ -42,7 +42,7 @@ **安装[PaddlePaddle](https://github.com/PaddlePaddle/Paddle):** -在当前目录下运行样例代码需要PadddlePaddle Fluid的v.1.4或以上的版本。如果你的运行环境中的PaddlePaddle低于此版本,请根据[安装文档](http://paddlepaddle.org/documentation/docs/zh/1.4/beginners_guide/install/index_cn.html)中的说明来更新PaddlePaddle。 +在当前目录下运行样例代码需要PadddlePaddle Fluid的v.1.5或以上的版本。如果你的运行环境中的PaddlePaddle低于此版本,请根据[安装文档](http://paddlepaddle.org/documentation/docs/zh/1.5/beginners_guide/install/index_cn.html)中的说明来更新PaddlePaddle。 ### 数据准备 diff --git a/PaddleCV/yolov3/README_en.md b/PaddleCV/yolov3/README_en.md index eed38195330058d0116c646684222c9827008073..c468cd8e010a3ee22804557fc7cf61168e871ee5 100644 --- a/PaddleCV/yolov3/README_en.md +++ b/PaddleCV/yolov3/README_en.md @@ -28,7 +28,7 @@ We also recommend users to take a look at the  [IPython Notebook demo](https:/ **Install [PaddlePaddle](https://github.com/PaddlePaddle/Paddle):** -Running sample code in this directory requires PaddelPaddle Fluid v.1.4 and later. If the PaddlePaddle on your device is lower than this version, please follow the instructions in [installation document](http://www.paddlepaddle.org/documentation/docs/en/1.4/beginners_guide/install/index_en.html) and make an update. +Running sample code in this directory requires PaddelPaddle Fluid v.1.5 and later. If the PaddlePaddle on your device is lower than this version, please follow the instructions in [installation document](http://www.paddlepaddle.org/documentation/docs/en/1.5/beginners_guide/install/index_en.html) and make an update. **Install the [COCO-API](https://github.com/cocodataset/cocoapi):** diff --git a/PaddleCV/yolov3/infer.py b/PaddleCV/yolov3/infer.py index fa8bb26cfd82caae732aaac6e829067e571360b3..e98e75020a931aa10e309dd306fe0558492d3f57 100644 --- a/PaddleCV/yolov3/infer.py +++ b/PaddleCV/yolov3/infer.py @@ -70,7 +70,8 @@ def infer(): im_shape = data[0][2] outputs = exe.run(fetch_list=[v.name for v in fetch_list], feed=feeder.feed(data), - return_numpy=False) + return_numpy=False, + use_program_cache=True) bboxes = np.array(outputs[0]) if bboxes.shape[1] != 6: print("No object found in {}".format(image_name)) diff --git a/PaddleCV/yolov3/models/yolov3.py b/PaddleCV/yolov3/models/yolov3.py index c84606252c7e29f581ba853c2e93a5e809c6f9d0..0feb2b0e2dfa21b56838cc9f1300a63402054bd0 100644 --- a/PaddleCV/yolov3/models/yolov3.py +++ b/PaddleCV/yolov3/models/yolov3.py @@ -68,17 +68,8 @@ def yolo_detection_block(input, channel, is_test=True, name=None): def upsample(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