faster-rcnn.pytorch-pytorch-1.0踩坑合集

  1. 在做rcnn项目时,把原数据集更换为乳腺癌数据集后,在运行demo.py遇到了报错:

RuntimeError: Error(s) in loading state_dict for resnet:

size mismatch for RCNN_cls_score.weight: copying a param with shape torch.Size([2, 2048]) from checkpoint, the shape in current model is torch.Size([21, 2048]).

size mismatch for RCNN_cls_score.bias: copying a param with shape torch.Size([2]) from checkpoint, the shape in current model is torch.Size([21]).

size mismatch for RCNN_bbox_pred.weight: copying a param with shape torch.Size([8, 2048]) from checkpoint, the shape in current model is torch.Size([84, 2048]).

size mismatch for RCNN_bbox_pred.bias: copying a param with shape torch.Size([8]) from checkpoint, the shape in current model is torch.Size([84]).

首先在网上查到的结果是更改config.py中的__C.ANCHOR_SCALES = [8,16,32]为 __C.ANCHOR_SCALES = [4,8,16,32]

更改之后发现还是有问题,因为网上更改的数据集为CoCo数据集。目前正在寻找解决方案;

找到解决方案,在demo.py文件中将

pascal_classes = np.asarray(['__background__',

'aeroplane', 'bicycle', 'bird', 'boat',

'bottle', 'bus', 'car', 'cat', 'chair',

'cow', 'diningtable', 'dog', 'horse',

'motorbike', 'person', 'pottedplant',

'sheep', 'sofa', 'train', 'tvmonitor'])

更改为:

pascal_classes = np.asarray(['__background__',

'tumour'])

成功解决问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值