Paddle deformable_conv crash

kfgdxczn  于 2021-12-07  发布在  Java
关注(0)|答案(2)|浏览(268)

CPU 1060
CUDA 10.0
PADLE 2.0
ubutun 16.04
docker 2.0rc linux 10.0
code:

!/usr/bin/env python3

from paddle.fluid.initializer import Constant
from paddle.fluid.param_attr import ParamAttr
import paddle
import paddle.fluid as fluid
import cv2
import numpy as np
from time import time
import paddle.nn.functional as F

class DcnModel(paddle.nn.Layer):
definit(self, name_scope, in_feature_number, out_feature_number, kernel_size):
super(DcnModel, self).init()
self.feature_number = in_feature_number
self.kernel_size = kernel_size
self.dcn_offset = paddle.nn.Conv2D(weight_attr=name_scope + '.offset',
bias_attr=name_scope + '.offset.bias',
in_channels=in_feature_number,
out_channels=kernel_size * kernel_size * 2,
kernel_size=kernel_size,
stride=1,
padding=kernel_size//2
)
self.dcn_amplitude = paddle.nn.Conv2D(weight_attr=name_scope + '.amplitude',
bias_attr=name_scope + '.amplitude.bias',
in_channels=in_feature_number,
out_channels=kernel_size*kernel_size,
kernel_size=kernel_size,
stride=1,
padding=kernel_size//2)
self.name_scope = name_scope

self.dcn_kernel = self.create_parameter(shape=[128, 128, 3, 3], attr=name_scope + '.kernel', dtype='float32')

self.dcn_name = name_scope + '.kernel'

self.dcn_conv = paddle.stastic.nn.deform_conv2d (x, offset, mask, num_filters, filter_size, stride=1, padding=0, dilation=1, groups=1, deformable_groups=1, im2col_step=1, weight_attr=None, bias_attr=None, name=None)

def forward(self, inputs):
B, C, H, W = inputs.shape
K = self.kernel_size

get offset [B, K * K * 2, H, W] via self.conv_offset

offset = self.dcn_offset(inputs)

reshape offset to [B, H, W, K * K, 2]

offset = offset.transpose((0, 2, 3, 1)).reshape((B, H, W, K * K, 2))

get amplitute [B, K*K, H, W]

amplitute = self.dcn_amplitude(inputs)
amplitute = F.sigmoid(amplitute)

dcn_kernel = np.array(self.dcn_kernel)

print(self.name_scope + '.kernel')

out_feature = paddle.fluid.layers.deformable_conv(
input= inputs,
offset=offset,
mask=amplitute,
num_filters=C,
filter_size=K,
stride=1,
padding=(K - 1) // 2,
groups=1,
deformable_groups=1,
im2col_step=1,
param_attr=ParamAttr(name=self.name_scope + '.kernel'),

param_attr=fluid.initializer.NumpyArrayInitializer(dcn_kernel),

bias_attr=False)
return out_feature

model = DcnModel(name_scope='dcn',
in_feature_number=128,
out_feature_number=128,
kernel_size=3)

x0 = paddle.ones((1,128,160,180))
i = 0
while(i < 100):
start1 = time()
out = model(x0)
out = out.numpy()
end1 = time()
print('Processed in {:0.03f} sec.'.format(end1 - start1))
i += 1

vngu2lb8

vngu2lb81#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

zbq4xfa0

zbq4xfa02#

paddle2.0rc 动态图暂时不支持deformable_conv,请先使用paddle develop, 或参考以下PR修改本地相关python文件:
#29364

相关问题