Ashoka74 commited on
Commit
5c1cf77
1 Parent(s): 155ab36

Update inference_i2mv_sdxl.py

Browse files
Files changed (1) hide show
  1. inference_i2mv_sdxl.py +5 -3
inference_i2mv_sdxl.py CHANGED
@@ -112,15 +112,17 @@ def remove_bg(image: Image.Image, net, transform, device, mask: Image.Image = No
112
 
113
 
114
  def preprocess_image(image: Image.Image, height, width):
115
- image = np.array(image)
116
  # alpha = image[..., 3] > 0
117
  # alpha = image
118
 
119
  if image.mode in ("RGBA", "LA"):
 
120
  alpha = image[..., 3] # Extract the alpha channel
121
  elif image.mode in ("RGB"):
122
- # Create default alpha for non-alpha images
123
- alpha = np.ones(image[..., 0].shape, dtype=np.uint8) * 255 # Create
 
124
  H, W = alpha.shape
125
  # get the bounding box of alpha
126
  y, x = np.where(alpha)
 
112
 
113
 
114
  def preprocess_image(image: Image.Image, height, width):
115
+
116
  # alpha = image[..., 3] > 0
117
  # alpha = image
118
 
119
  if image.mode in ("RGBA", "LA"):
120
+ image = np.array(image)
121
  alpha = image[..., 3] # Extract the alpha channel
122
  elif image.mode in ("RGB"):
123
+ image = np.array(image)
124
+ # Create default alpha for non-alpha images
125
+ alpha = np.ones(image[..., 0].shape, dtype=np.uint8) * 255 # Create
126
  H, W = alpha.shape
127
  # get the bounding box of alpha
128
  y, x = np.where(alpha)