61 Star 651 Fork 254

PaddlePaddle / PaddleDetection

 / 详情

Windows下读取 yml文件报错

待办的
创建于  
2020-09-30 10:32

运行命令:

C:\Users\Huan\Anaconda3\envs\py37\python.exe E:/projects/python/paddle_learn/PaddleDetection/tools/train.py -c configs/yolov3_mobilenet_v1_roadsign.yml --use_vdl=true --vdl_log_dir=vdl_dir/scalar --eval

错误日志:

Traceback (most recent call last):
  File "E:/projects/python/paddle_learn/PaddleDetection/tools/train.py", line 375, in <module>
    main()
  File "E:/projects/python/paddle_learn/PaddleDetection/tools/train.py", line 70, in main
    cfg = load_config(FLAGS.config)
  File "E:\projects\python\paddle_learn\PaddleDetection\ppdet\core\workspace.py", line 86, in load_config
    cfg = merge_config(yaml.load(f, Loader=yaml.Loader), cfg)
  File "C:\Users\Huan\Anaconda3\envs\py37\lib\site-packages\yaml\__init__.py", line 112, in load
    loader = Loader(stream)
  File "C:\Users\Huan\Anaconda3\envs\py37\lib\site-packages\yaml\loader.py", line 44, in __init__
    Reader.__init__(self, stream)
  File "C:\Users\Huan\Anaconda3\envs\py37\lib\site-packages\yaml\reader.py", line 85, in __init__
    self.determine_encoding()
  File "C:\Users\Huan\Anaconda3\envs\py37\lib\site-packages\yaml\reader.py", line 124, in determine_encoding
    self.update_raw()
  File "C:\Users\Huan\Anaconda3\envs\py37\lib\site-packages\yaml\reader.py", line 178, in update_raw
    data = self.stream.read(size)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position 41: illegal multibyte sequence

问题文件:
PaddleDetection\ppdet\core\workspace.py

cfg = AttrDict()
with open(file_path) as f:

问题原因:
文件open时没有指定 encoding='UTF-8',使用GBK打开yml

修改如下:

cfg = AttrDict()
with open(file_path, encoding='UTF-8') as f:

评论 (0)

凌蓝风 创建了任务
展开全部操作日志

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
Python
1
https://gitee.com/paddlepaddle/PaddleDetection.git
git@gitee.com:paddlepaddle/PaddleDetection.git
paddlepaddle
PaddleDetection
PaddleDetection

搜索帮助