open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.74k stars 9.48k forks source link

UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 34: illegal multibyte sequence #8291

Open zhjr2019 opened 2 years ago

zhjr2019 commented 2 years ago

"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\python.exe" D:/zhjrProjects/source/OpenMMLab/MMDetection/tools/train.py ../configs/balloon/mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_balloon.py Traceback (most recent call last): File "D:\zhjrProjects\source\OpenMMLab\MMDetection\tools\train.py", line 242, in main() File "D:\zhjrProjects\source\OpenMMLab\MMDetection\tools\train.py", line 114, in main cfg = replace_cfg_vals(cfg) File "D:\zhjrProjects\source\OpenMMLab\MMDetection\mmdet\utils\replace_cfg_vals.py", line 64, in replace_cfg_vals updated_cfg = Config( File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\site-packages\mmcv\utils\config.py", line 405, in init text = f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 34: illegal multibyte sequence

Process finished with exit code 1

zhjr2019 commented 2 years ago

按照官网设置:https://mmdetection.readthedocs.io/zh_CN/latest/2_new_data_model.html IDE:PyCharm 另外指出一个官网配置文件问题: image

chhluo commented 2 years ago

Re-new the config file with encoding='utf-8' may help you.

wrywst commented 2 years ago

i have the same problem,

lavender37 commented 1 year ago

change the config.py in line 405 with specifying the encoding UTF-8 may help you

        if cfg_text:
            text = cfg_text
        elif filename:
            with open(filename, encoding='UTF-8') as f:
                text = f.read()
        else:
            text = ''