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

UnicodeDecodeError: 'gbk' codec can't decode byte 0xab in position 408: illegal multibyte sequence #420

Open
HappyBookroom opened this issue Dec 6, 2024 · 0 comments

Comments

@HappyBookroom
Copy link

I encountered a problem while debugging this project, mainly due to the file encoding format.
----->>
Traceback (most recent call last):
File "E:\PyCharm_2023\Learn_Pytorch\YOLOv4\ScaledYOLOv4-yolov4-large\train.py", line 443, in
train(hyp, opt, device, tb_writer)
File "E:\PyCharm_2023\Learn_Pytorch\YOLOv4\ScaledYOLOv4-yolov4-large\train.py", line 53, in train
data_dict = yaml.load(f, Loader=yaml.FullLoader) # model dict
File "E:\Anaconda3\envs\torch\lib\site-packages\yaml_init_.py", line 79, in load
loader = Loader(stream)
File "E:\Anaconda3\envs\torch\lib\site-packages\yaml\loader.py", line 24, in init
Reader.init(self, stream)
File "E:\Anaconda3\envs\torch\lib\site-packages\yaml\reader.py", line 85, in init
self.determine_encoding()
File "E:\Anaconda3\envs\torch\lib\site-packages\yaml\reader.py", line 124, in determine_encoding
self.update_raw()
File "E:\Anaconda3\envs\torch\lib\site-packages\yaml\reader.py", line 178, in update_raw
data = self.stream.read(size)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xab in position 408: illegal multibyte sequence

In the train.py file, make the following modifications(Lines 49 to 57):
'''

# Configure
cuda = device.type != 'cpu'
init_seeds(2 + rank)
with open(opt.data,encoding='utf-8') as f:
    data_dict = yaml.load(f, Loader=yaml.FullLoader)  # model dict
train_path = data_dict['train']
test_path = data_dict['val']
nc, names = (1, ['item']) if opt.single_cls else (int(data_dict['nc']), data_dict['names'])  # number classes, names
assert len(names) == nc, '%g names found for nc=%g dataset in %s' % (len(names), nc, opt.data)  # check

'''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant