matthewearl / deep-anpr

Using neural networks to build an automatic number plate recognition system
MIT License
1.84k stars 698 forks source link

UnicodeEncodeError: 'utf-8' codec can't encode character in Python3, but Python2 not display. #91

Open ZengyuanYu opened 6 years ago

ZengyuanYu commented 6 years ago

code: def read_data(img_glob): for fname in sorted(glob.glob(img_glob)):

fname = fname.decode('utf-8')

    # fname = fname.encode('utf-8')
    im = cv2.imread(fname)[:, :, 0].astype(numpy.float32) / 255.
    code = fname.split("/")[1][9:16]
    p = fname.split("/")[1][17] == '1'
    yield im, code_to_vec(p, code)

return: Traceback (most recent call last): File "/home/yu/Templates/E2E-detection-and-track/deep-anpr/train.py", line 271, in initial_weights=initial_weights) File "/home/yu/Templates/E2E-detection-and-track/deep-anpr/train.py", line 237, in train test_xs, test_ys = unzip(list(read_data("test/*.png"))[:50]) File "/home/yu/Templates/E2E-detection-and-track/deep-anpr/train.py", line 66, in read_data im = cv2.imread(fname)[:, :, 0].astype(numpy.float32) / 255. UnicodeEncodeError: 'utf-8' codec can't encode character '\udc8f' in position 14: surrogates not allowed what can i do ? i still find the bug but don't solve it.