Incubator-mxnet: Suport Chinese Characters in file Path

Created on 26 Nov 2020  路  2Comments  路  Source: apache/incubator-mxnet

Description

Env: Win10/Python3.7.9 x64/mxnet_cu102-1.7.0-py2.py3-none-win_amd64.whl from https://dist.mxnet.io/python/cu102

import os
import mxnet as mx
img_fp = r'D:\PythonDev\DocManagement\books\鎭兘姘戦棿鏁呬簨閫塡page-1.png'
assert os.path.isfile(img_fp)
img = mx.image.imread(img_fp, 1)

Error Message

锟硷考 File "D:\PythonDev\DocManagement\mxnet_test.py", line 5, in <module>
  img = mx.image.imread(img_fp, 1)
File "c:\Python37\Lib\site-packages\mxnet\image\image.py", line 93, in imread
  return read_fn(filename, *args, **kwargs)
File "<string>", line 37, in _cvimread
File "c:\Python37\Lib\site-packages\mxnet\_ctypes\ndarray.py", line 91, in _imperative_invoke
  ctypes.byref(out_stypes)))
File "c:\Python37\Lib\site-packages\mxnet\base.py", line 246, in check_call
  raise get_last_ffi_error()

mxnet.base.MXNetError: Traceback (most recent call last):
File "C:\Jenkins\workspace\mxnet-tag\mxnet\src\io\image_io.cc", line 223
Imread: Check failed: file.is_open(): 'D:\PythonDev\DocManagement\books\鎭兘姘戦棿鏁呬簨閫塡page-1.png' couldn't open file: No such file or directory
Bug OpenCV

All 2 comments

@honglei thanks for reporting. mx.image.imread is a thin wrapper of opencv's imread, which doesn't seem to support utf-8 paths. For now I think you can use the following workaround:
mx.image.imdecode(np.fromfile(img_fp, dtype='uint8'))

@szha Yes锛宨t was caused by cv2.imread. Many Thanks. The issue is here: https://github.com/opencv/opencv/issues/18305

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sbodenstein picture sbodenstein  路  3Comments

luoruisichuan picture luoruisichuan  路  3Comments

WangcsShuai picture WangcsShuai  路  3Comments

dushoufu picture dushoufu  路  3Comments

yuconglin picture yuconglin  路  3Comments