본문 바로가기
프로그래밍/Python

[Python] create_lmdb_dataset.py error 해결

by rahites 2022. 12. 26.

# 눈도 잘 안 보이는데 무슨 부귀영화를 누리겠다고 코드치다가 에러해결로 시간을 다 날렸다..!!

 

1. 문제의 원인

https://github.com/clovaai/deep-text-recognition-benchmark

 

GitHub - clovaai/deep-text-recognition-benchmark: Text recognition (optical character recognition) with deep learning methods.

Text recognition (optical character recognition) with deep learning methods. - GitHub - clovaai/deep-text-recognition-benchmark: Text recognition (optical character recognition) with deep learning ...

github.com

OCR을 해보겠다고 검색을 해가며 TRBA(TPS-ResNet-BiLSTM-Attn)를 써보기 위해 Dataset을 생성하던 중 아래와 같은 에러가 발생했다. (lmdb Error)

 

2. 문제의 해결

결론부터 말하자면 create_lmdb_dataset.py의 코드를 아래와 같이 수정해주니 해결되었다.

# 이전
env = lmdb.open(outputPath, map_size=1099511627776)

# 이후
env = lmdb.open(outputPath, map_size=1073741824)
 

Why ouccpy error lmdb create dataset · Issue #189 · clovaai/deep-text-recognition-benchmark

Hi. I created lmdb dataset on my own data by running create_lmdb_dataset.py. then I run the train command on it and got the following output: Traceback (most recent call last): File "create_lm...

github.com

Ubuntu에서는 위의 코드가 되지만 Window에서는 아래로 실행해야 된다고 한다.
(Github에서는 위의 값에서 /1024를 써주라고 나와있는데 그 값이 위의 값이다)
 
 
 

3. 다른 문제의 발생과 해결

- 위의 문제를 해결하고 나니 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 문제가 발생하였는데 이는 해결방법이 간단했다. createDataset 함수에서 utf-8로 읽어오던걸 cp949로 인코딩을 변경해주니 해결되었다!

- SyntaxError: Non-UTF-8 code starting with '\xed' in file <FilePath> but no encoding declared 문제는 train.py 코드 맨 위에 아래의 코드를 넣으면 해결되었다!! (#도 포함해서 넣어주는 것! )

# -*- coding: utf-8 -*-

 

 

잘 돌아가는 것을 확인할 수 있다!!

 

댓글