Toybrick

pytorch ConvTranspose2d出错.版本1.4.0

一袋米要扛几楼

新手上路

积分
22
楼主
发表于 2020-9-14 19:09:13    查看: 16798|回复: 8 | [复制链接]    打印 | 只看该作者
class Darknet(nn.Module):
    """YOLOv3 object detection model"""

    def __init__(self, config_path, img_size=448):
        super(Darknet, self).__init__()
        self.img_size = img_size
        self.seen = 0
        self.blocks = []
        self.yolo_layers = []

        innitial_channel = 1
        self.block2 = creat_block_maxpool(3, innitial_channel * 1, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1), pool_kernel=(2, 2), pool_stride=(2, 2))
        self.block4 = creat_block_maxpool(innitial_channel * 1, innitial_channel * 2, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1), pool_kernel=(2, 2), pool_stride=(2, 2))
        self.block6 = creat_block_maxpool(innitial_channel * 2, innitial_channel * 4, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1), pool_kernel=(2, 2), pool_stride=(2, 2))

        self.block8 = creat_block(innitial_channel * 4, innitial_channel * 8, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block9 = nn.MaxPool2d(kernel_size=(2, 2), stride=(2, 2), padding=0)

        self.block10 = creat_block(innitial_channel * 8, innitial_channel * 16, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block11 = nn.MaxPool2d(kernel_size=(2, 2), stride=(1, 1), padding=0)

        self.block12 = creat_block(innitial_channel * 16, innitial_channel * 32, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block13 = creat_block(innitial_channel * 32, innitial_channel * 8, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block14 = creat_block(innitial_channel * 8, innitial_channel * 16, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block15_yolo1 = creat_block(innitial_channel * 16, 3*(5+1), conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))

        # self.block17 = 13
        self.block18 = creat_block(innitial_channel * 8, innitial_channel * 4, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block19 = torch.nn.ConvTranspose2d(innitial_channel * 4, innitial_channel * 8, kernel_size=3, stride=2, padding=0, output_padding=1, bias=True)
        # self.block20_rote = 19+8
        self.block21 = creat_block(innitial_channel * 8, innitial_channel * 16, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block22 = creat_block(innitial_channel * 16, innitial_channel * 16, conv_kernel=(3, 3), conv_stride=(1, 1), conv_padding=(1, 1))
        self.block23_yolo2 = nn.Conv2d(innitial_channel * 16, 3*(5+1), kernel_size=3, stride=1, padding=1)

    def forward(self, x):

        x2 = self.block2(x)
        x4 = self.block4(x2)
        x6 = self.block6(x4)
        x8 = self.block8(x6)
        x9 = self.block9(x8)
        x10 = self.block10(x9)
        x11 = self.block11(x10)
        x12 = self.block12(x11)
        x13 = self.block13(x12)

        x14 = self.block14(x13)
        x15 = self.block15_yolo1(x14)

        x18 = self.block18(x13)# return x19 之前的结果运行通过,return x19之后的结果报错。也就是torch.nn.ConvTranspose2d
        x19 = self.block19(x18)
        # # print(x_8.shape, x_19.shape)
        x20 = x8 + x19

        x21 = self.block21(x20)
        x22 = self.block22(x21)
        x23 = self.block23_yolo2(x22)
        # return x23 #报错
        return x15, x18 #通过rk版本1.4.0--> config model
done
--> Loading model

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/co ... 7-contrib-sunset.md
  * https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.

/usr/local/lib/python3.5/dist-packages/onnx_tf/common/__init__.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release.. Use node.outputs instead.
  warnings.warn(message)
./rknn_models_test2/yoloV3.pt ********************
WARNING: Token 'COMMENT' defined, but not used
WARNING: There is 1 unused token
E Try match aten::_convolution_at_x19.1ut0 failed, catch exception!
E Catch exception when loading pytorch model: ./rknn_models_test2/yoloV3.pt!
E Traceback (most recent call last):
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 1567, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.match_paragraph_and_param
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 1444, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch._torch_try_match_ruler
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
E During handling of the above exception, another exception occurred:
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 657, in rknn.api.rknn_base.RKNNBase.load_pytorch
E   File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 104, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 1590, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.match_paragraph_and_param
E   File "rknn/api/rknn_log.py", line 312, in rknn.api.rknn_log.RKNNLog.e
E ValueError: Try match aten::_convolution_at_x19.1ut0 failed, catch exception!
Load pytorch model failed!


回复

使用道具 举报

jefferyzhang

版主

积分
13572
沙发
发表于 2020-9-14 22:26:07 | 只看该作者
置顶帖的qq群里问问
回复

使用道具 举报

一袋米要扛几楼

新手上路

积分
22
板凳
 楼主| 发表于 2020-9-15 08:38:40 | 只看该作者
jefferyzhang 发表于 2020-9-14 22:26
置顶帖的qq群里问问

好的谢谢
回复

使用道具 举报

一袋米要扛几楼

新手上路

积分
22
地板
 楼主| 发表于 2020-9-15 08:43:56 | 只看该作者
jefferyzhang 发表于 2020-9-14 22:26
置顶帖的qq群里问问

555555,原谅我没找到QQ群,能给我帖一个吗?
回复

使用道具 举报

jefferyzhang

版主

积分
13572
5#
发表于 2020-9-15 09:08:31 | 只看该作者
一袋米要扛几楼 发表于 2020-9-15 08:43
555555,原谅我没找到QQ群,能给我帖一个吗?

置顶贴就有:http://t.rock-chips.com/forum.ph ... &extra=page%3D1
回复

使用道具 举报

一袋米要扛几楼

新手上路

积分
22
6#
 楼主| 发表于 2020-9-15 09:30:50 | 只看该作者
jefferyzhang 发表于 2020-9-15 09:08
置顶贴就有:http://t.rock-chips.com/forum.php?mod=viewthread&tid=1967&extra=page%3D1

get,
回复

使用道具 举报

xiaqing10

高级会员

积分
572
7#
发表于 2021-1-12 14:08:55 | 只看该作者
nn.ConvTranspose2d 这个rknn 还不支持,用upsample来代替。
回复

使用道具 举报

changchenliang

注册会员

积分
125
8#
发表于 2021-4-13 15:37:38 | 只看该作者
xiaqing10 发表于 2021-1-12 14:08
nn.ConvTranspose2d 这个rknn 还不支持,用upsample来代替。

请问目前最新的rknn1.6.0支持nn.ConvTranspose2d了吗?
我的网络里有nn.ConvTranspose2d运算,在之前的rknn1.4.0+torch1.2.0版本下竟然能正确转化和推理,但是放到目前的rknn1.6.0+torch1.6.0下就出错了, 这好奇怪啊?? 这是为何。。
回复

使用道具 举报

bobby_jiang

高级会员

积分
546
9#
发表于 2021-4-16 17:54:36 | 只看该作者
最新的rknn1.6.0支持nn.ConvTranspose2d。
你要检查,你的计算棒固件是否升级到最新版本了?请按照wiki在线升级到最新的1.6.0版本。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表