Kaynağa Gözat

convert RGB to BGR by default in image writer when the backend is opencv but img obj is Image type (#3310)

Tingquan Gao 9 ay önce
ebeveyn
işleme
bbb8adabc0
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  1. 2 1
      paddlex/inference/utils/io/writers.py

+ 2 - 1
paddlex/inference/utils/io/writers.py

@@ -312,7 +312,8 @@ class OpenCVImageWriterBackend(_ImageWriterBackend):
     def _write_obj(self, out_path, obj):
         """write image object by OpenCV"""
         if isinstance(obj, Image.Image):
-            arr = np.asarray(obj)
+            # Assuming the channel order is RGB.
+            arr = np.asarray(obj)[:, :, ::-1]
         elif isinstance(obj, np.ndarray):
             arr = obj
         else: