Convert
-
[flask] python - UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start bytePrograming/python 2021. 11. 22. 10:42
flask로 백엔드 서버를 구축중이다. 문제 발생의 주요 부분은, 프론트로부터 전달받은 이미지(bytes) 파일을 celery worker에게 전달해주는 과정에서 bytes 전송시 string으로 형변환 해서 넘겨줘야한다. (message broker는 'redis' 사용) 그런데, decode('utf-8') 함수를 사용해 bytes to string 형변환을 하니 아래와 같은 에러가 뜬다. UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte 파이썬은 기본적으로 'utf-8' 문자 포맷을 사용하는데 전달받은 이미지 파일의 포맷이 달라서 생기는 문제였다. (utf-16이라는 말이 있음) 실제로 ..
-
How to convert pt to tflite (yolov5 to tensorflow lite) tflite로 변환AI 2021. 1. 19. 16:18
업데이트: 이걸로 해결 github.com/zldrobit/yolov5/blob/tf-android/models/tf.py $ python models/tf.py --weights weights/best.pt --cfg models/yolov5s.yaml --img-size 320 yolov5로 학습된 모델을 1차적으로 Android에서 사용하고자 한다. 그럴러면 최종적으로 .pt 파일을 .tflite로 변환해야한다. 그게 한번에 되냐? 아쉽게도 pt -> onnx -> pb -> tflite 순으로 변환해야한다. 명령어 하나로 되었다면 얼마나 좋았을까.. 그래서 그 과정에서 꽤 많은 삽질을 하게 되었다. 잠깐 언급하자면 tensorflow 버전과 onnx 버전의 호환성.. 버전업되면서 바뀐것도 많고 알..