再启动原来代码进行新的模型训练突然出现codeDecodeError: 'gbk'编码问题,作一次记录。
启动训练具体信息如下:
COMET INFO: Using 'D:\\pycharmProject\\yolov5-master-6.2\\.cometml-runs' path as offline directory. Pass 'offline_directory' parameter into constructor or set the 'COMET_OFFLINE_DIRECTORY' environment variable to manually choose where to store offline experiment archives.
COMET WARNING: Native output logging mode is not available, falling back to basic output logging
Traceback (most recent call last):
File "D:\pycharmProject\yolov5-master-6.2old\train.py", line 630, in <module>
main(opt)
File "D:\pycharmProject\yolov5-master-6.2old\train.py", line 526, in main
train(opt.hyp, opt, device, callbacks)
File "D:\pycharmProject\yolov5-master-6.2old\train.py", line 94, in train
loggers = Loggers(save_dir, weights, opt, hyp, LOGGER) # loggers instance
File "D:\pycharmProject\yolov5-master-6.2old\utils\loggers\__init__.py", line 132, in __init__
self.comet_logger = CometLogger(self.opt, self.hyp)
File "D:\pycharmProject\yolov5-master-6.2old\utils\loggers\comet\__init__.py", line 97, in __init__
self.data_dict = self.check_dataset(self.opt.data)
File "D:\pycharmProject\yolov5-master-6.2old\utils\loggers\comet\__init__.py", line 232, in check_dataset
data_config = yaml.safe_load(f)
File "D:\ProgramData\Anaconda3\lib\site-packages\yaml\__init__.py", line 125, in safe_load
return load(stream, SafeLoader)
File "D:\ProgramData\Anaconda3\lib\site-packages\yaml\__init__.py", line 79, in load
loader = Loader(stream)
File "D:\ProgramData\Anaconda3\lib\site-packages\yaml\loader.py", line 34, in __init__
Reader.__init__(self, stream)
File "D:\ProgramData\Anaconda3\lib\site-packages\yaml\reader.py", line 85, in __init__
self.determine_encoding()
File "D:\ProgramData\Anaconda3\lib\site-packages\yaml\reader.py", line 124, in determine_encoding
self.update_raw()
File "D:\ProgramData\Anaconda3\lib\site-packages\yaml\reader.py", line 179, in update_raw
data = self.stream.read(size)
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 233: illegal multibyte sequence
<_io.TextIOWrapper name='data\\coco128.yaml' mode='r' encoding='cp936'> ---------------------
COMET INFO: Couldn't find a Git repository in 'D:\\pycharmProject\\yolov5-master-6.2old' nor in any parent directory. Set `COMET_GIT_DIRECTORY` if your Git Repository is elsewhere.
COMET WARNING: Unknown error exporting current conda environment
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Comet.ml OfflineExperiment Summary
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Data:
COMET INFO: display_summary_level : 1
COMET INFO: url : [OfflineExperiment will get URL after upload]
COMET INFO: Others:
COMET INFO: offline_experiment : True
COMET INFO: Uploads:
COMET INFO: conda-info : 1
COMET INFO: conda-specification : 1
COMET INFO: environment details : 1
COMET INFO: installed packages : 1
COMET INFO:
COMET WARNING: Experiment Name is generated at upload time for Offline Experiments unless set explicitly with Experiment.set_name
COMET WARNING: To get all data logged automatically, import comet_ml before the following modules: tensorboard, torch.
COMET INFO: Still saving offline stats to messages file before program termination (may take up to 120 seconds)
COMET INFO: Starting saving the offline archive
COMET INFO: To upload this offline experiment, run:
comet upload D:\pycharmProject\yolov5-master-6.2\.cometml-runs\bf6f678f442649758c6ec09340cd9b34.zip
跟踪定位:读取配置文件coco128.yaml时报编码错,怀疑出现了特殊字符
最后发现注释数据目录列表报错如下:
# parent
# ├── yolov5
# └── datasets
# └── coco128 ← downloads here (7 MB)
解决办法:
删除上面注释部分后,测试通过。提供解决问题思路,配置文件有特殊字符(如汉字特殊字符),慢慢删除测试
yolov5的6.2早期版本有该问题,6.2后期版本没有该问题。