未验证 提交 6862da6a 编写于 作者: K Kaipeng Deng 提交者: GitHub

Cherry pick remove actual shape (#3620)

* remove actual_shape

* change version to 1.5 in yolov3
上级 333b3620
...@@ -148,18 +148,8 @@ class YOLOv3Head(object): ...@@ -148,18 +148,8 @@ class YOLOv3Head(object):
return route, tip return route, tip
def _upsample(self, input, scale=2, name=None): 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( out = fluid.layers.resize_nearest(
input=input, scale=scale, actual_shape=out_shape, name=name) input=input, scale=float(scale), name=name)
return out return out
def _parse_anchors(self, anchors): def _parse_anchors(self, anchors):
......
...@@ -87,13 +87,8 @@ class FPN(object): ...@@ -87,13 +87,8 @@ class FPN(object):
learning_rate=2., learning_rate=2.,
regularizer=L2Decay(0.)), regularizer=L2Decay(0.)),
name=lateral_name) 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( 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 return lateral + topdown
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
**安装[PaddlePaddle](https://github.com/PaddlePaddle/Paddle):** **安装[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。
### 数据准备 ### 数据准备
......
...@@ -28,7 +28,7 @@ We also recommend users to take a look at the  [IPython Notebook demo](https:/ ...@@ -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):** **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):** **Install the [COCO-API](https://github.com/cocodataset/cocoapi):**
......
...@@ -70,7 +70,8 @@ def infer(): ...@@ -70,7 +70,8 @@ def infer():
im_shape = data[0][2] im_shape = data[0][2]
outputs = exe.run(fetch_list=[v.name for v in fetch_list], outputs = exe.run(fetch_list=[v.name for v in fetch_list],
feed=feeder.feed(data), feed=feeder.feed(data),
return_numpy=False) return_numpy=False,
use_program_cache=True)
bboxes = np.array(outputs[0]) bboxes = np.array(outputs[0])
if bboxes.shape[1] != 6: if bboxes.shape[1] != 6:
print("No object found in {}".format(image_name)) print("No object found in {}".format(image_name))
......
...@@ -68,17 +68,8 @@ def yolo_detection_block(input, channel, is_test=True, name=None): ...@@ -68,17 +68,8 @@ def yolo_detection_block(input, channel, is_test=True, name=None):
def upsample(input, scale=2, 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( out = fluid.layers.resize_nearest(
input=input, scale=scale, actual_shape=out_shape, name=name) input=input, scale=float(scale), name=name)
return out return out
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册