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 0x80 in position 233: illegal multibyte sequence #13462

Open
2 tasks done
zhangsiying2001 opened this issue Dec 16, 2024 · 2 comments
Labels
bug Something isn't working devops GitHub Devops or MLops

Comments

@zhangsiying2001
Copy link

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

D:\0_yyyzt\AIM\yolo\yolov5> python train.py --weights yolov5s.pt --epochs 300 --batch-size 16 --workers 8 --data D:\0_yyyzt\AIM\yolo\datasets\zhengtu\zhengtu.yaml
train: weights=yolov5s.pt, cfg=, data=D:\0_yyyzt\AIM\yolo\datasets\zhengtu\zhengtu.yaml, hyp=data\hyps\hyp.scratch-low.yaml, epochs=300, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, evolve_population=data\hyps, resume_evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs\train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest, ndjson_console=False, ndjson_file=False
github: up to date with https://github.com/ultralytics/yolov5
YOLOv5 v7.0-389-ge62a31b6 Python-3.11.9 torch-2.5.1+cpu CPU

hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
TensorBoard: Start with 'tensorboard --logdir runs\train', view at http://localhost:6006/
COMET WARNING: Comet credentials have not been set. Comet will default to offline logging. Please set your credentials to enable online logging.
COMET INFO: Using 'D:\0_yyyzt\AIM\yolo\yolov5\.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.
Traceback (most recent call last):
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 986, in
main(opt)
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 688, in main
train(opt.hyp, opt, device, callbacks)
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 180, in train
loggers = Loggers(
^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers_init_.py", line 153, in init
self.comet_logger = CometLogger(self.opt, self.hyp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers\comet_init_.py", line 102, in init
self.data_dict = self.check_dataset(self.opt.data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers\comet_init_.py", line 252, in check_dataset
data_config = yaml.safe_load(f)
^^^^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml_init_.py", line 125, in safe_load
return load(stream, SafeLoader)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml_init_.py", line 79, in load
loader = Loader(stream)
^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\loader.py", line 34, in init
Reader.init(self, stream)
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 85, in init
self.determine_encoding()
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 124, in determine_encoding
self.update_raw()
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 178, in update_raw
data = self.stream.read(size)
^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 233: illegal multibyte sequence
COMET INFO: The process of logging environment details (conda environment, git patch) is underway. Please be patient as this may take some time.
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Comet.ml OfflineExperiment Summary
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Data:
COMET INFO: display_summary_level : 1
COMET INFO: name : exp
COMET INFO: url : [OfflineExperiment will get URL after upload]
COMET INFO: Others:
COMET INFO: Name : exp
COMET INFO: offline_experiment : True
COMET INFO: Uploads:
COMET INFO: environment details : 1
COMET INFO: git metadata : 1
COMET INFO: installed packages : 1
COMET INFO:
COMET INFO: Still saving offline stats to messages file before program termination (may take up to 120 seconds)
COMET INFO: Begin archiving the offline data.
COMET INFO: To upload this offline experiment, run:
comet upload D:\0_yyyzt\AIM\yolo\yolov5.cometml-runs\e9b6f27f962c4a25bfeb02399ccf699f.zip

Environment

OS=win py=3.11.9 use=cpu NoUse NVIDIA

Minimal Reproducible Example

D:\0_yyyzt\AIM\yolo\yolov5> python train.py --weights yolov5s.pt --epochs 300 --batch-size 16 --workers 8 --data D:\0_yyyzt\AIM\yolo\datasets\zhengtu\zhengtu.yaml
train: weights=yolov5s.pt, cfg=, data=D:\0_yyyzt\AIM\yolo\datasets\zhengtu\zhengtu.yaml, hyp=data\hyps\hyp.scratch-low.yaml, epochs=300, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, evolve_population=data\hyps, resume_evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs\train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest, ndjson_console=False, ndjson_file=False
github: up to date with https://github.com/ultralytics/yolov5
YOLOv5 v7.0-389-ge62a31b6 Python-3.11.9 torch-2.5.1+cpu CPU

hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
TensorBoard: Start with 'tensorboard --logdir runs\train', view at http://localhost:6006/
COMET WARNING: Comet credentials have not been set. Comet will default to offline logging. Please set your credentials to enable online logging.
COMET INFO: Using 'D:\0_yyyzt\AIM\yolo\yolov5\.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.
Traceback (most recent call last):
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 986, in
main(opt)
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 688, in main
train(opt.hyp, opt, device, callbacks)
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 180, in train
loggers = Loggers(
^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers_init_.py", line 153, in init
self.comet_logger = CometLogger(self.opt, self.hyp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers\comet_init_.py", line 102, in init
self.data_dict = self.check_dataset(self.opt.data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers\comet_init_.py", line 252, in check_dataset
data_config = yaml.safe_load(f)
^^^^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml_init_.py", line 125, in safe_load
return load(stream, SafeLoader)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml_init_.py", line 79, in load
loader = Loader(stream)
^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\loader.py", line 34, in init
Reader.init(self, stream)
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 85, in init
self.determine_encoding()
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 124, in determine_encoding
self.update_raw()
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 178, in update_raw
data = self.stream.read(size)
^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 233: illegal multibyte sequence
COMET INFO: The process of logging environment details (conda environment, git patch) is underway. Please be patient as this may take some time.
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Comet.ml OfflineExperiment Summary
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Data:
COMET INFO: display_summary_level : 1
COMET INFO: name : exp
COMET INFO: url : [OfflineExperiment will get URL after upload]
COMET INFO: Others:
COMET INFO: Name : exp
COMET INFO: offline_experiment : True
COMET INFO: Uploads:
COMET INFO: environment details : 1
COMET INFO: git metadata : 1
COMET INFO: installed packages : 1
COMET INFO:
COMET INFO: Still saving offline stats to messages file before program termination (may take up to 120 seconds)
COMET INFO: Begin archiving the offline data.
COMET INFO: To upload this offline experiment, run:
comet upload D:\0_yyyzt\AIM\yolo\yolov5.cometml-runs\e9b6f27f962c4a25bfeb02399ccf699f.zip

Additional

D:\0_yyyzt\AIM\yolo\yolov5> python train.py --weights yolov5s.pt --epochs 300 --batch-size 16 --workers 8 --data D:\0_yyyzt\AIM\yolo\datasets\zhengtu\zhengtu.yaml
train: weights=yolov5s.pt, cfg=, data=D:\0_yyyzt\AIM\yolo\datasets\zhengtu\zhengtu.yaml, hyp=data\hyps\hyp.scratch-low.yaml, epochs=300, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, evolve_population=data\hyps, resume_evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs\train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest, ndjson_console=False, ndjson_file=False
github: up to date with https://github.com/ultralytics/yolov5
YOLOv5 v7.0-389-ge62a31b6 Python-3.11.9 torch-2.5.1+cpu CPU

hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
TensorBoard: Start with 'tensorboard --logdir runs\train', view at http://localhost:6006/
COMET WARNING: Comet credentials have not been set. Comet will default to offline logging. Please set your credentials to enable online logging.
COMET INFO: Using 'D:\0_yyyzt\AIM\yolo\yolov5\.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.
Traceback (most recent call last):
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 986, in
main(opt)
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 688, in main
train(opt.hyp, opt, device, callbacks)
File "D:\0_yyyzt\AIM\yolo\yolov5\train.py", line 180, in train
loggers = Loggers(
^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers_init_.py", line 153, in init
self.comet_logger = CometLogger(self.opt, self.hyp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers\comet_init_.py", line 102, in init
self.data_dict = self.check_dataset(self.opt.data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\0_yyyzt\AIM\yolo\yolov5\utils\loggers\comet_init_.py", line 252, in check_dataset
data_config = yaml.safe_load(f)
^^^^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml_init_.py", line 125, in safe_load
return load(stream, SafeLoader)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml_init_.py", line 79, in load
loader = Loader(stream)
^^^^^^^^^^^^^^
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\loader.py", line 34, in init
Reader.init(self, stream)
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 85, in init
self.determine_encoding()
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 124, in determine_encoding
self.update_raw()
File "C:\Users\1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\yaml\reader.py", line 178, in update_raw
data = self.stream.read(size)
^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 233: illegal multibyte sequence
COMET INFO: The process of logging environment details (conda environment, git patch) is underway. Please be patient as this may take some time.
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Comet.ml OfflineExperiment Summary
COMET INFO: ---------------------------------------------------------------------------------------
COMET INFO: Data:
COMET INFO: display_summary_level : 1
COMET INFO: name : exp
COMET INFO: url : [OfflineExperiment will get URL after upload]
COMET INFO: Others:
COMET INFO: Name : exp
COMET INFO: offline_experiment : True
COMET INFO: Uploads:
COMET INFO: environment details : 1
COMET INFO: git metadata : 1
COMET INFO: installed packages : 1
COMET INFO:
COMET INFO: Still saving offline stats to messages file before program termination (may take up to 120 seconds)
COMET INFO: Begin archiving the offline data.
COMET INFO: To upload this offline experiment, run:
comet upload D:\0_yyyzt\AIM\yolo\yolov5.cometml-runs\e9b6f27f962c4a25bfeb02399ccf699f.zip

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@zhangsiying2001 zhangsiying2001 added the bug Something isn't working label Dec 16, 2024
@UltralyticsAssistant UltralyticsAssistant added the devops GitHub Devops or MLops label Dec 16, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @zhangsiying2001, thank you for your interest in YOLOv5 🚀! It looks like you're encountering a UnicodeDecodeError while training.

If this is a 🐛 Bug Report, please ensure you've included a minimum reproducible example (MRE) for us to investigate. Based on the provided log, the issue seems related to file encoding. It would be helpful if you could:

  1. Confirm the encoding of your .yaml file (e.g., use UTF-8 encoding).
  2. Share the contents of the file causing the issue, ensuring no sensitive information is included.
  3. Test running YOLOv5 using the recommended Python version and dependencies to rule out potential compatibility issues.

Requirements

  • Make sure you are using Python >= 3.8 and have all dependencies correctly installed. Running the command to install dependencies after cloning the repository can help ensure this.

Environments

YOLOv5 can be run in various environments (local machine, cloud-based notebooks, or containers). Verify your environment is properly configured, especially for platform-specific settings like file encodings on Windows.

This is an automated response to help you get started. An Ultralytics engineer will take a closer look shortly to assist further 😊.

@pderrenger
Copy link
Member

The UnicodeDecodeError indicates an issue with reading your YAML file due to encoding mismatches. Ensure that your zhengtu.yaml file is saved with UTF-8 encoding. On Windows, you can do this using text editors like Notepad++ or Visual Studio Code by selecting "Save with Encoding" as UTF-8. After saving, try running the script again. Let me know if the issue persists!

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

No branches or pull requests

3 participants