【可变形卷积3】 DCNv2 安装

使用RTM3D 代码,CenterTrack代码需要用DCN

1、安装DCNv2

  • (1)github上最新版的DCNv2源码在"https://github.com/CharlesShang/DCNv2",但是该版本源码不支持PyTorch1.7,如果使其支持PyTorch1.7需要做以下修改:
    将DCNv2/src/cuda/dcn_v2_cuda.cu中所有的THCState_getCurrentStream(state)替换成c10::cuda::getCurrentCUDAStream()。

  • (2)github上有支持PyTorch1.7的源码,“https://github.com/lbin/DCNv2/tree/pytorch_1.7”,可以直接使用。

2、 Deformable Convolutional Networks V2 with Pytorch 1.0,不支持PyTorch1.7

Build

    ./make.sh         # build
    python test.py    # run examples and gradient check 

An Example

  • deformable conv
    from dcn_v2 import DCN
    input = torch.randn(2, 64, 128, 128).cuda()
    # wrap all things (offset and mask) in DCN
    dcn = DCN(64, 64, kernel_size=(3,3), stride=1, padding=1, deformable_groups=2).cuda()
    output = dcn(input)
    print(output.shape)
  • deformable roi pooling
    from dcn_v2 import DCNPooling
    input = torch.randn(2, 32, 64, 64).cuda()
    batch_inds = torch.randint(2, (20, 1)).cuda().float()
    x = torch.randint(256, (20, 1)).cuda().float()
    y = torch.randint(256, (20, 1)).cuda().float()
    w = torch.randint(64, (20, 1)).cuda().float()
    h = torch.randint(64, (20, 1)).cuda().float()
    rois = torch.cat((batch_inds, x, y, x + w, y + h), dim=1)

    # mdformable pooling (V2)
    # wrap all things (offset and mask) in DCNPooling
    dpooling = DCNPooling(spatial_scale=1.0 / 4,
                         pooled_size=7,
                         output_dim=32,
                         no_trans=False,
                         group_size=1,
                         trans_std=0.1).cuda()

    dout = dpooling(input, rois)

Note

Now the master branch is for pytorch 1.0 (new ATen API), you can switch back to pytorch 0.4 with,

git checkout pytorch_0.4

3、pytorch代码

https://github.com/HiYx/pytorch-deform-conv-v2

4、mmdet 的DCN

可以直接使用mmdet 的DCN。

5、附录


在这里插入图片描述


在这里插入图片描述

6、可参考

https://blog.csdn.net/wangxiao7474/article/details/113605230

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hali_Botebie

文中错误请不吝指正!!!!!!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值