diff --git a/utils/datasets.py b/utils/datasets.py index 8627344af7b4..f212e54633be 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -32,6 +32,9 @@ segments2boxes, xyn2xy, xywh2xyxy, xywhn2xyxy, xyxy2xywhn) from utils.torch_utils import torch_distributed_zero_first +# Remap +cv2.imread = lambda x: cv2.imdecode(np.fromfile(x, np.uint8), cv2.IMREAD_COLOR) # for Chinese filenames + # Parameters HELP_URL = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data' IMG_FORMATS = 'bmp', 'dng', 'jpeg', 'jpg', 'mpo', 'png', 'tif', 'tiff', 'webp' # include image suffixes diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 866bdc4be2f5..ff6722ecd48a 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -148,6 +148,9 @@ def on_train_end(self, last, best, plots, epoch, results): 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')