yolov7源码调试中的坑

下载yolov7源码之后,发现有很多坑,估计一一记录。

1. 在train.py中的参数与配置文件中的参数的优先级?

如图所示,我将yaml文件的地址如下parser.add_argument('--data', type=str, default='NEU-DET/data.yaml', help='data.yaml path'),对应的yaml文件如下图所示。

#yaml
train: D:\\python\\yolov7-main\\NEU-DET\\train\\images
val: D:\\python\\yolov7-main\\NEU-DET\\valid\\images

nc: 6
names: ['crazing', 'inclusion', 'patches', 'pitted_surface', 'rolled-in_scale', 'scratches']

在这里插入图片描述
结果训练时候却报错,说找不到train.txt文件。
在这里插入图片描述
train.txt也没有发现问题:
在这里插入图片描述
这个坑头有点大,我找变了所有的py文件,搜索之下没有任何D:\\PycharmProject\\yolov7-main\\NEU-DET\\train.txt这个路径的结果。于是我查看了打开了train.py的配置文件。我发现这里有一个配置的脚本为:

--workers
1
--device
0
--batch-size
4
--data
data/neu.yaml
--cfg
cfg/training/yolov7.yaml
--weights
yolov7.pt
--name
yolov7
--hyp
data/hyp.scratch.p5.yaml
--epochs
20

在这里插入图片描述
我打开了对应的--data data/neu.yaml文件,发现如下:。原来问题出现在配置脚本中。最后得出结论,这个配置文件优先级高于train.py中的配置参数。

# COCO 2017 dataset http://cocodataset.org

# download command/URL (optional)
download: bash ./scripts/get_coco.sh

# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
train: D:\\PycharmProject\\yolov7-main\\NEU-DET\\train.txt
val: D:\\PycharmProject\\yolov7-main\\NEU-DET\\val.txt
#test: ./coco/test-dev2017.txt  # 20288 of 40670 images, submit to https://competitions.codalab.org/competitions/20794

# number of classes
nc: 6

# class names
names: ['crazing', 'inclusion', 'patches', 'pitted_surface', 'rolled-in_scale', 'scratches']

2.报错如下,这是因为numpy的版本问题,早期版本使用的np.int已经被弃用。

AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:

按照如下方式进行一一改进(主要是dataset.py和general有这种书写问题)

# Old code
x = np.array([1, 2, 3], dtype=np.int)

# New code
x = np.array([1, 2, 3], dtype=int)

OK终于开始跑了
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

又又土

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

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

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

打赏作者

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

抵扣说明:

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

余额充值