qhgz2013 / anime-face-detector

A Faster-RCNN based anime face detector implementation using tensorflow.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Japanese filenames cause an error

opened this issue · comments

$ python main.py -i ~/Desktop/a/ -crop-location ~/Desktop/b/
[1/144] Elapsed: 0:00.000, ETA: 0:00.000 >> C:/Users/me/Desktop/a/censored_cg05a.png
[2/144] Elapsed: 0:03.402, ETA: 8:06.521 >> C:/Users/me/Desktop/a/censored_cg05b.png
[3/144] Elapsed: 0:05.996, ETA: 7:05.748 >> C:/Users/me/Desktop/a/censored_cg05c.png
[4/144] Elapsed: 0:08.626, ETA: 6:45.443 >> C:/Users/me/Desktop/a/censored_cg05d.png
[5/144] Elapsed: 0:11.273, ETA: 6:34.558 >> C:/Users/me/Desktop/a/censored_cg14a.png
[6/144] Elapsed: 0:13.825, ETA: 6:24.344 >> C:/Users/me/Desktop/a/censored_ct07a.png
[7/144] Elapsed: 0:16.278, ETA: 6:14.415 >> C:/Users/me/Desktop/a/cg08ax2.png
Traceback (most recent call last):
  File "main.py", line 187, in <module>
    main()
  File "main.py", line 138, in main
    print('[%d/%d] Elapsed: %s, ETA: %s >> %s' % (idx+1, file_len, fmt_time(elapsed), fmt_time(eta), file))
  File "C:\Users\me\AppData\Local\Programs\Python\Python38\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 70-72: character maps to <undefined>
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile

It's failing on this

If I rename them with only ascii, it works.

So I think it crashes on print() because Git Bash doesn't support unicode or something and python isn't outputting in unicode... If I run it in powershell it gets past the print but crashes somewhere else.

[1/78] Elapsed: 0:00.000, ETA: 0:00.000 >> C:\Users\me\Desktop\h\cg05a.png
[2/78] Elapsed: 0:03.399, ETA: 4:21.731 >> C:\Users\me\Desktop\h\cg05b.png
[3/78] Elapsed: 0:05.946, ETA: 3:45.956 >> C:\Users\me\Desktop\h\cg05c.png
[4/78] Elapsed: 0:08.462, ETA: 3:31.555 >> C:\Users\me\Desktop\h\cg05d.png
[5/78] Elapsed: 0:11.034, ETA: 3:24.140 >> C:\Users\me\Desktop\h\cg09a.png
libpng warning: iCCP: known incorrect sRGB profile
[6/78] Elapsed: 0:13.562, ETA: 3:18.006 >> C:\Users\me\Desktop\h\cg09b.png
libpng warning: iCCP: known incorrect sRGB profile
[7/78] Elapsed: 0:16.258, ETA: 3:15.097 >> C:\Users\me\Desktop\h\cg09c.png
libpng warning: iCCP: known incorrect sRGB profile
[8/78] Elapsed: 0:18.793, ETA: 3:10.622 >> C:\Users\me\Desktop\h\cg09カットイン1a.png
Traceback (most recent call last):
  File "main.py", line 187, in <module>
    main()
  File "main.py", line 140, in main
    scores, boxes = detect(sess, net, img)
  File "main.py", line 14, in detect
    img_origin = image.astype(np.float32, copy=True)
AttributeError: 'NoneType' object has no attribute 'astype'

That's because img = cv2.imread(file) only supports ASCII path, this will be fixed next time. Use other packages like pillow can fix this problem, for example, changing img = cv2.imread(file) to:

from PIL import Image
import numpy as np
img = np.asarray(Image.open(file), dtype='uint8')