Skip to content

Commit c1ca660

Browse files
committed
fix: use cv2.imdecode to support reading files with Chinese characters in filename
1 parent 5955254 commit c1ca660

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

paddlex/inference/utils/io/readers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ def __init__(self, flags=None):
267267

268268
def read_file(self, in_path):
269269
"""read image file from path by OpenCV"""
270-
return cv2.imread(in_path, flags=self.flags)
270+
with open(in_path, "rb") as f:
271+
img_array = np.frombuffer(f.read(), np.uint8)
272+
return cv2.imdecode(img_array, flags=self.flags)
271273

272274

273275
class PILImageReaderBackend(_ImageReaderBackend):

0 commit comments

Comments
 (0)