DSFNet(Dynamic and Static Fusion Network for Moving Object Detection in Satellite Videos)代码调试

帮人解决的论文代码,分享以下经验,小的安装问题就不叙述了,分析主要问题:

问题一:DCNv2的配置

运行之前还需配置好DCN,在./lib/model/DCNv2/下面因为DSFNET.py等都需要DCN网络

代码自带的DCNv2总是无法setup,报错cuda和gcc编译器问题,太麻烦,应此另辟蹊径,不使用代码自带的DCNv2,使用mmcv中的DCN实现。

首先下载安装mmcv库:

# 命令行输入:
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
# 将其中的{cu_version}替换为你的CUDA版本,{torch_version}替换为你已经安装的pytorch版本;
# 例如:CUDA 为11.0,pytorch为1.7.0
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html

 刚开始一直安装不上,后面发现是信任问题,因此改为如下,将安装网站用trusted-host转换

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu116/torch1.13.0/index.html --trusted-host download.openmmlab.com

在代码中替换

from mmcv.ops import DeformConv2dPack as DCN

# 使用方法与官方DCNv2一样,只不过deformable_groups参数名改为deform_groups即可,例如:
dconv2 = DCN(in_channel, out_channel, kernel_size=(3, 3), stride=(2, 2), padding=1, deform_groups=2)

 在原论文代码中就是将DSFNET.py、DSFNET_with_Dynamic.py、DSFNET_with_Static.py中DCN的引用做替换:

# from lib.models.DCNv2.dcn_v2 import DCN
from mmcv.ops import DeformConv2dPack as DCN

问题二:原代码的get_pose_net函数未定义

在DSFNET.py、DSFNET_with_Dynamic.py、DSFNET_with_Static.py中都提到了get_pose_net,但代码中并未定义,这其实是伪函数,需要自己定义网络如下:

在DSFNET.py中

if __name__ == '__main__':
    # net = get_pose_net({'hm': 1, 'wh': 2, 'reg': 2}, 256)
    net = DSFNet({'hm': 1, 'wh': 2, 'reg': 2}, 256)
    total = sum([param.nelement() for param in net.parameters()])
    print('   Number of params: %.2fM' % (total / 1e6))

在DSFNET_with_Dynamic.py中

if __name__ == '__main__':
    # net = get_pose_net({'hm': 1, 'wh': 2, 'reg': 2}, 256)
    net = DSFNet_with_Dynamic({'hm': 1, 'wh': 2, 'reg': 2}, 256)
    total = sum([param.nelement() for param in net.parameters()])
    print('   Number of params: %.2fM' % (total / 1e6))

在DSFNET_with_Static.py中

if __name__ == '__main__':
    # net = get_pose_net({'hm': 1, 'wh': 2, 'reg': 2}, 256)
    net = DSFNet_with_Static({'hm': 1, 'wh': 2, 'reg': 2}, 256)
    total = sum([param.nelement() for param in net.parameters()])
    print('   Number of params: %.2fM' % (total / 1e6))

问题三:pycocotools安装问题

pip install pycocotools是不行的,需使用git

pip install git+https://gitee.com/pursuit_zhangyu/cocoapi.git#subdirectory=PythonAPI

 如果requirements.txt中的cython、scipy等都没安装就会报错,需安装完后安装pycocotools

问题四:其他杂项

还是说一下其他杂项吧

1、在/Moving-object-detection-DSFNet-main/lib/utils/opts.py中有很多初始化定义,比如权重文件的保存位置,显卡调用数量等,需根据自身情况调整

2、数据需要保存在/Moving-object-detection-DSFNet-main/data/中,自己建立

3、其他小问题我记不住了,欢迎提问!

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值