yolov5 데이터를 돌릴 때
yaml 파일을 수정하는데 있어서 오류가 발생 햇다.
import yaml
with open(home_path + '/data.yaml','r') as f :
data = yaml.load(f)
발생 원인은 PyYAML5.1 버전 이상 부터는 yaml.load()를 지원 하지 않는다고 한다.
PyYAML는 파이썬에서의 yaml 파일을 parser , emitter 하는 라이브러리 이다.
PyYAML 5.1 버전 이상인 경우
버전을 내려도 되겠지만 아래 참고의 사이트를 보고 코드를 수정 햇다.
with open(home_path + '/data.yaml','r') as f :
data = yaml.load(f,Loader=yaml.SafeLoader)
# 아래 방법은 추천 하지 않는다고 써있다. 이전 yaml.loda(f)와 같이
# 악용될 가능성이 있다고 경고한다.
with open(home_path + '/data.yaml','r') as f :
data = yaml.load(f,Loader=yaml.FullLoader)
SafeLoade
Loads a subset of the YAML language, safely. This is recommended for loading untrusted input.
FullLoader
Loads the full YAML language. Avoids arbitrary code execution. This is currently (PyYAML 5.1+) the default loader called by yaml.load(input) (after issuing the warning).
등 더 많은 loader option은 아래 사이트 들어가면 더 나온다.
# 참고
https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation