Fix for *.yaml emojis on load (#5543)
Browse filesFix 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
```
- models/yolo.py +1 -1
@@ -90,7 +90,7 @@ class Model(nn.Module):
|
|
90 |
else: # is *.yaml
|
91 |
import yaml # for torch hub
|
92 |
self.yaml_file = Path(cfg).name
|
93 |
-
with open(cfg, errors='ignore') as f:
|
94 |
self.yaml = yaml.safe_load(f) # model dict
|
95 |
|
96 |
# Define model
|
|
|
90 |
else: # is *.yaml
|
91 |
import yaml # for torch hub
|
92 |
self.yaml_file = Path(cfg).name
|
93 |
+
with open(cfg, encoding='ascii', errors='ignore') as f:
|
94 |
self.yaml = yaml.safe_load(f) # model dict
|
95 |
|
96 |
# Define model
|