0


yolov8 路径问题

训练时,报错:data.yaml does not exist

!yolo task=detect mode=train model=yolov8n.pt data=data.yaml

解决办法:

写绝对路径:

!yolo task=detect mode=train model=yolov8n.pt data=/home/{username}/{xxx}/{xxx}/datasets/data.yaml

data.ymal 里path的配置也要是绝对路径:

# path: ../datasets/{your_project}  # dataset root dir
path: /home/{username}/{xxx}/{xxx}/datasets/{your_project}  # dataset root dir

原因

  1. cli 传参 https://github.com/ultralytics/ultralytics/blob/790f9c067c9a3548acf7c6925cea14de9ad77787/ultralytics/yolo/cfg/__init__.py#L183
  2. train https://github.com/ultralytics/ultralytics/blob/790f9c067c9a3548acf7c6925cea14de9ad77787/ultralytics/yolo/engine/model.py#L294
  3. 初始化trainer https://github.com/ultralytics/ultralytics/blob/790f9c067c9a3548acf7c6925cea14de9ad77787/ultralytics/yolo/engine/trainer.py#L75
  4. 获取参数 https://github.com/ultralytics/ultralytics/blob/790f9c067c9a3548acf7c6925cea14de9ad77787/ultralytics/yolo/cfg/__init__.py#L87
  5. 加载data.ymal https://github.com/ultralytics/ultralytics/blob/790f9c067c9a3548acf7c6925cea14de9ad77787/ultralytics/yolo/engine/trainer.py#L122
  6. 拼接data.ymal 文件路径 https://github.com/ultralytics/ultralytics/blob/790f9c067c9a3548acf7c6925cea14de9ad77787/ultralytics/yolo/data/utils.py#L220![在这里插入图片描述](https://img-blog.csdnimg.cn/6a52d9350bbe4a3f8334f57767d9dbdb.png) 这里可以看到,如果不写成绝对路径,则按DATASETS_DIR去拼接, 过程是:yolo先找到user_config_dir /home/{user}/.config, 第一次运行yolo项目A时,会在下面创建/home/{user}/.config/Ultralytics 和/home/{user}/.config/Ultralytics/settings.yaml setting.ymal 里会有DATASETS_DIR,值就是项目A的datasets路径。

datasets_dir: /home/{user}/{projectA}/datasets


本文转载自: https://blog.csdn.net/weixin_42754054/article/details/129424820
版权归原作者 weixin_42754054 所有, 如有侵权,请联系我们删除。

“yolov8 路径问题”的评论:

还没有评论