Bug解决方案汇总

1.成功解决AttributeError: module ‘cv2.cv2’ has no attribute ‘xfeatures2d’

  • 原因:opencv自3.4.2.17之后的版本,就不支持该方法了。
  • 解决办法:
    • python2:
      • pip uninstall opencv-contrib-python
      • pip install opencv-contrib-python==3.4.2.17
    • python3:
      • python3 -m pip uninstall opencv-contrib-python
      • python3 -m pip install opencv-contrib-python==3.4.2.17
  • 拓展:
    • xfeatures2d:做特征检测与匹配,在物体检测,视觉跟踪,三维重建等领域都有广泛的应用,内置有SIFT、SURF、ORB 、AKAZE
  • 参考链接:https://www.jianshu.com/p/0a5991223306

2.全局变量报错:UnboundLocalError: local variable ‘l’ referenced before assignment

  • 原因:
    • 当搜索一个变量的时候,python先从局部作用域开始搜索,如果在局部作用域没有找到那个变量,那样python就在全局变量中找这个变量,如果找不到抛出异常(NAMEERROR或者Unbound-LocalError,这取决于python版本。)
    • 如果内部函数有引用外部函数的同名变量或者全局变量,并且对这个变量有修改.那么python会认为它是一个局部变量,又因为函数中没有sum的定义和赋值,所以报错。
import sys
sum=5
def add(a=1,b=3):
    print(a,b)
    print(sum)  #内部函数引用同名变量,并且修改这个变量。python会认为它是局部变量。因为在此处print之前,没有定义sum变量,所以会报错(建议与情况一比较,备注:此处只是比上例先print sum)
    sum=b+a
    print(sum)
add(4,8)
print sum

3.成功解决TypeError: ‘int’ object is not callable

  • 原因:python中变量名和方法名相同,当这两个名称重复时,程序会默认调用Int型对象
  • 解决办法:更换变量名

4.成功解决resize错误:cv2.error: OpenCV(4.6.0) /io/opencv/modules/imgproc/src/resize.cpp:3930: error: (-215:Assertion failed) func != 0 in function ‘resize’

  • 原因:
    • 可能原因1:路径错误
    • 可能原因2:输入图像的维度正确的是(h,w,3),但是经过下面的两个函数后,输入图像的变为(w,h,3),比如用了transpose交换两个维度
    • 最终原因:输入的是int类型,应该输入float类型
  • 解决办法:input = input.astype(float)

5.Mac 错误zsh: command not found: brew解决方法

  • 原因:需要安装brew
  • 解决办法:
    • /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

6.fatal: not in a git directory Error: Command failed with exit 128: git

  • 原因:

    • 用户设置 homebrew-cask 和 homebrew-core 的文件路径为设置为safe.directory
  • 解决办法:

    • git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
    • git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
  • 参考链接:https://blog.csdn.net/Morris_/article/details/125182905

7.client_loop: send disconnect: Broken pipe

8.gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting

tar -zxvf v1.0-trainval01_blobs.tar报错

  • 解决办法:tar xvf v1.0-trainval01_blobs.tar

9. TypeError: can’t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

  • 原因:
  • 解决办法:inputs = torch.tensor([item.cpu().detach().numpy() for item in inputs]).cuda()
  • 注:不能直接对input().cpu(),因为input是list

10.RuntimeError: MaskRCNN: [enforce fail at inline_container.cc:145] . PytorchStreamReader failed reading zip archive: failed finding central directory

  • 原因:加载的pth权重不完整( failed reading zip),因为在下载权重过程中断了

11.ModuleNotFoundError: No module named ‘numba.errors’

  • 解决办法:
    • pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade numba
    • pip install -i https://pypi.tuna.tsinghua.edu.cn/simple llvmlite==0.31.0
    • pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed llvmlite

12.AssertionError: CocoDataset: Incompatible version of pycocotools is installed. Run pip uninstall pycocotools first. Then run pip install mmpycocotools to install open-mmlab forked pycocotools.(BEVFusion)

  • 原因:网络上是重新安装pycocotools和mmpycocotools,但是要降低版本
  • 解决办法:
    • pip install mmpycocotools==12.0.2
    • pip install pycocotools==2.0.1

13.RuntimeError: radix_sort: failed on 1st step: cudaErrorInvalidDevice: invalid device ordinal(BEVFusion)

  • 原因:torch版本不对
  • 解决办法:显卡是3090,最后安装的是python==3.7,pytorch=1.9.0,cuda=11.1

14.ImportError: libXrender.so.1: cannot open shared object file: No such file or directory

import mayavi.mlab as mlab

的时候出现

  • 原因:
    • 这个错误通常发生在尝试导入Mayavi库时,它需要libXrender库来正常工作,但是找不到该库文件。
  • 解决办法:
    • 解决这个问题的一种方法是安装缺少的库文件。在Ubuntu或Debian系统上,可以使用以下命令安装libXrender库:sudo apt-get install libxrender1

15. raise RuntimeError(message) from e RuntimeError: Error compiling objects for extension

安装DCNv2

sh make.sh

的时候出现

  • 原因:
    • DCNv2 0.1版本和torch冲突
  • 解决办法:
    • 我的是cuda11.1,去DCNv2 官网下载DCNv2-pytorch_1.9,替换原来的DCNv2文件夹,重新安装
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

凌青羽

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值