windows yolov5 代码运行train.py时报错:
File "D:\Anaconda\envs\torch2\lib\site-packages\yaml\loader.py", line 34, in __init__
Reader.__init__(self, stream)
File "D:\Anaconda\envs\torch2\lib\site-packages\yaml\reader.py", line 85, in __init__
self.determine_encoding()
File "D:\Anaconda\envs\torch2\lib\site-packages\yaml\reader.py", line 124, in determine_encoding
self.update_raw()
File "D:\Anaconda\envs\torch2\lib\site-packages\yaml\reader.py", line 178, in update_raw
data = self.stream.read(size)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 238: illegal multibyte sequence
看起来像是编码解码错误;
前面都是系统的代码,最后追述yolov5自定义的代码到这句:
data_dict = yaml.safe_load(f) # data dict
网上搜索后,根据参考链接1修改为:
with open(data, "r", encoding='UTF-8') as f:
就好了,但是后面又有其它错误,慢慢改之吧;