np.fromfile() Chinese image paths fix (#6979)

* 🎉 🆕 now can read Chinese image path. 

use "cv2.imdecode(np.fromfile(f, np.uint8), cv2.IMREAD_COLOR)" instead of "cv2.imread(f)" for Chinese image path.

* Update datasets.py

* Update __init__.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
yeshanliuandGlenn Jocher authored and GitHub committed 2022-03-23 15:35:15 +01:00
1 parent c3ae4e4af6
commit bc3ed957ce
2 files changed
+6

No files matched your search

+3
View File
@@ -148,6 +148,9 @@ class Loggers():
if self.tb:
import cv2
import numpy as np
cv2.imread = lambda x: cv2.imdecode(np.fromfile(x, np.uint8), cv2.IMREAD_COLOR) # remap for Chinese files
for f in files:
self.tb.add_image(f.stem, cv2.imread(str(f))[..., ::-1], epoch, dataformats='HWC')