当前位置:   article > 正文

YOLOv8 debug记录_attributeerror: 'nonetype' object has no attribute

attributeerror: 'nonetype' object has no attribute '_free_weak_ref

1.模型卡在yolov8m summary

 解决方案:请确保下述代码中的权重路径正确(图例中应使yolov8m.pt与train.py文件处在同级目录)

  1. from ultralytics import YOLO
  2. # Load a model
  3. model = YOLO('yolov8m.yaml') # build a new model from YAML
  4. model = YOLO('yolov8m.pt') # load a pretrained model (recommended for training)
  5. model = YOLO('yolov8m.yaml').load('yolov8m.pt') # build from YAML and transfer weights
  6. # Train the model
  7. model.train(data='VisDrone.yaml', epochs=100, imgsz=640)

2.卡在AMP阶段

解决方案:这个问题查了很多博客至今我都没有找到解决方案不知道是不是我服务器哪有问题,我自己的解决方案是在设置amp = False,如下所示。但并不算是完全解决只能算暂时规避吧。

  1. # Train the model
  2. model.train(data='VisDrone.yaml', epochs=200, imgsz=640, amp =False)

3.代码训练阶段出现

AttributeError: 'NoneType' object has no attribute '_free_weak_ref'

解决方案:这个报错信息经查是由于torch版本引起的,确保torch>1.12.0Training yolov8 throws an error - AttributeError: 'NoneType' object has no attribute '_free_weak_ref' - PyTorch Forums

 最简单的方法就是pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

(避免网络问题可以加上-i 使用清华镜像)

4.运行train.py后卡在加载权重部分

此错误信息我暂时还没有遇到,但是在查阅相关的博客时发现有其他的报告过这个bug,所以加上供他人参考

解决方案:yolov8代码中在model.py(文件路径如下所示)中的line 354

存在语句

check_pip_update_available()

该代码会检查项目文件是否为最新,因为墙的问题可能会存在网络缓慢固代码文件卡住,注释后代码正常

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号