Sfoglia il codice sorgente

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

Tingquan Gao 9 mesi fa
parent
commit
bbb8adabc0
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  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: