Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

转换标注失败'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence #51

Closed
kwanxian opened this issue Sep 5, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@kwanxian
Copy link

kwanxian commented Sep 5, 2023

windows 10
python 3.10

(.venv) D:\Projects\X-AnyLabeling>python tools/label_converter.py --src_path source/valid/ --dst_path source/valid/ --mode custom2yolo

# 报错信息如下
 File "D:\Projects\X-AnyLabeling\tools\label_converter.py", line 162, in custom_to_yolov5
    data = json.load(f.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence
@CVHub520
Copy link
Owner

CVHub520 commented Sep 6, 2023

您好,这个是文件编码问题,网上有很多参考解决方案,例如这个,可以自行搜索下。

@CVHub520 CVHub520 added the bug Something isn't working label Sep 6, 2023
@kwanxian
Copy link
Author

kwanxian commented Sep 8, 2023

您好,这个是文件编码问题,网上有很多参考解决方案,例如这个,可以自行搜索下。

确认JSON文件是utf8编码,PY文件也是utf8编码,with open 时也指定utf8。
如果指定utf8,则会报 0xff开头错误。

@CVHub520
Copy link
Owner

您好,@kwanxian ,如果方便的话可以提供下你的图片和JSON文件打包发我下。

@seejah
Copy link

seejah commented Sep 11, 2023

这个问题解决了吗?我也遇到了同样的问题

@seejah
Copy link

seejah commented Sep 11, 2023

File "D:\DeveFolder\X-AnyLabeling\tools\label_converter.py", line 251, in custom_to_coco
data = json.load(f)
File "C:\Program Files\Python310\lib\json_init_.py", line 293, in load
return loads(fp.read(),
UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence

如果把250行处的with open,加上encoding='utf-8',提示又变成:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
说明也不对?

@CVHub520
Copy link
Owner

您好,@seejah ,可以提供下相关文件打包给我下吗,这边复现下。

@seejah
Copy link

seejah commented Sep 11, 2023 via email

@seejah
Copy link

seejah commented Sep 11, 2023

您好,@seejah ,可以提供下相关文件打包给我下吗,这边复现下。

邮件已发送,期待好消息!

@CVHub520
Copy link
Owner

您好,@seejah ,可以提供下相关文件打包给我下吗,这边复现下。

邮件已发送,期待好消息!

您好,可以发送到指定邮箱:cv_hub@163.com

@CVHub520
Copy link
Owner

@kwanxian @seejah 您好,bug 已修复,请更新代码重新转换,有问题欢迎随时反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants