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

Fix for *.yaml emojis on load #5543

Merged
merged 1 commit into from
Nov 6, 2021
Merged

Fix for *.yaml emojis on load #5543

merged 1 commit into from
Nov 6, 2021

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Nov 6, 2021

Fix for Colab hub error:

import yaml

with open('yolov5s.yaml', errors='ignore') as f:
     d = yaml.safe_load(f)  # model dict

print(d)

---------------------------------------------------------------------------
ReaderError                               Traceback (most recent call last)
<ipython-input-8-1150b5143073> in <module>()
      2 
      3 with open('yolov5s.yaml', errors='ignore') as f:
----> 4      d = yaml.safe_load(f)  # model dict
      5 
      6 print(d)

6 frames
/usr/local/lib/python3.7/dist-packages/yaml/reader.py in check_printable(self, data)
    142             position = self.index+(len(self.buffer)-self.pointer)+match.start()
    143             raise ReaderError(self.name, position, ord(character),
--> 144                     'unicode', "special characters are not allowed")
    145 
    146     def update(self, length):

ReaderError: unacceptable character #x1f680: special characters are not allowed
  in "yolov5s.yaml", position 9

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved file reading compatibility in YOLO model initialization.

📊 Key Changes

  • Changed file opening method by specifying encoding='ascii' during YOLO model configuration file reading.

🎯 Purpose & Impact

  • 🛠️ Purpose: Enhances compatibility with different system environments, ensuring files are read correctly regardless of the default system encoding.
  • 💻 Impact: Users may experience fewer errors when initializing YOLO models, particularly on systems with non-ASCII default encodings. This small but crucial change can help in avoiding character encoding-related bugs.

Fix for Colab hub error:


```python
import yaml

with open('yolov5s.yaml', errors='ignore') as f:
     d = yaml.safe_load(f)  # model dict

print(d)

---------------------------------------------------------------------------
ReaderError                               Traceback (most recent call last)
<ipython-input-8-1150b5143073> in <module>()
      2 
      3 with open('yolov5s.yaml', errors='ignore') as f:
----> 4      d = yaml.safe_load(f)  # model dict
      5 
      6 print(d)

6 frames
/usr/local/lib/python3.7/dist-packages/yaml/reader.py in check_printable(self, data)
    142             position = self.index+(len(self.buffer)-self.pointer)+match.start()
    143             raise ReaderError(self.name, position, ord(character),
--> 144                     'unicode', "special characters are not allowed")
    145 
    146     def update(self, length):

ReaderError: unacceptable character #x1f680: special characters are not allowed
  in "yolov5s.yaml", position 9
```
@glenn-jocher glenn-jocher self-assigned this Nov 6, 2021
@glenn-jocher glenn-jocher merged commit 60c8a4f into master Nov 6, 2021
@glenn-jocher glenn-jocher deleted the fix/yaml_emoji branch November 6, 2021 15:03
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
Fix for Colab hub error:


```python
import yaml

with open('yolov5s.yaml', errors='ignore') as f:
     d = yaml.safe_load(f)  # model dict

print(d)

---------------------------------------------------------------------------
ReaderError                               Traceback (most recent call last)
<ipython-input-8-1150b5143073> in <module>()
      2 
      3 with open('yolov5s.yaml', errors='ignore') as f:
----> 4      d = yaml.safe_load(f)  # model dict
      5 
      6 print(d)

6 frames
/usr/local/lib/python3.7/dist-packages/yaml/reader.py in check_printable(self, data)
    142             position = self.index+(len(self.buffer)-self.pointer)+match.start()
    143             raise ReaderError(self.name, position, ord(character),
--> 144                     'unicode', "special characters are not allowed")
    145 
    146     def update(self, length):

ReaderError: unacceptable character #x1f680: special characters are not allowed
  in "yolov5s.yaml", position 9
```
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

Successfully merging this pull request may close these issues.

None yet

1 participant