pytorch-retinanet

参考代码

# 编译 nms 
cd pytorch-retinanet/lib
bash build.sh

出现如下问题,是因为,参考的代码中 pytorch==0.4, 我使用 pytorch=1.0
ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead
解决方法:

cd nms
rm -rf /build
rm *.so
cd ..
python setup3.py build_ext --inplace
#at last,you need modify code in model.py:
#from lib.nms.pth_nms import pth_nms
from lib.nms.gpu_nms import gpu_nms
and
#return pth_nms(dets, thresh)
return gpu_nms(dets, thresh)
raise error:
TypeError: Argument 'dets' has incorrect type (expected numpy.ndarray, got Tensor)

我的解决方式是:

# anchors_nms_idx = nms(torch.cat([transformed_anchors, scores], dim=2)[0, :, :], 0.5) 
anchors_nms_idx = nms(torch.cat([transformed_anchors, scores], dim=2)[0, :, :].cpu().numpy(), 0.5) 
# 再 visualize.py 中添加
scores = scores.cpu().numpy()

上述issue中解决方式是(这种方式可能需要重新编译):

# you need change the dets to numpy:
add in gpu_nms() :
dets = dets.numpy()

cv2 退出窗口

k = cv2.waitKey(0)  # waitkey代表读取键盘的输入,括号里的数字代表等待多长时间,单位ms。 0代表一直等待
if k == 27:  # 键盘上Esc键的键值
	cv2.destroyAllWindows()
	break  # 终止循环
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值