p1atdev commited on
Commit
5b9b0e3
·
verified ·
1 Parent(s): db283a4

fix: RGB to BGR

Browse files
Files changed (1) hide show
  1. image_processing_tagger.py +8 -0
image_processing_tagger.py CHANGED
@@ -118,6 +118,14 @@ def resize_with_padding(
118
 
119
  new_image = new_image.convert("RGB")
120
 
 
 
 
 
 
 
 
 
121
  if return_numpy:
122
  new_image = np.array(new_image)
123
  # If the input image channel dimension was of size 1, then it is dropped when converting to a PIL image
 
118
 
119
  new_image = new_image.convert("RGB")
120
 
121
+ # Convert to numpy array
122
+ image_array = np.asarray(new_image, dtype=np.float32)
123
+
124
+ # Convert PIL-native RGB to BGR
125
+ image_array = image_array[:, :, ::-1]
126
+
127
+ new_image = Image.fromarray(image_array.astype(np.uint8))
128
+
129
  if return_numpy:
130
  new_image = np.array(new_image)
131
  # If the input image channel dimension was of size 1, then it is dropped when converting to a PIL image