Spaces:
Running
on
Zero
Running
on
Zero
Update inference_i2mv_sdxl.py
Browse files- inference_i2mv_sdxl.py +7 -1
inference_i2mv_sdxl.py
CHANGED
@@ -114,7 +114,13 @@ def remove_bg(image: Image.Image, net, transform, device, mask: Image.Image = No
|
|
114 |
def preprocess_image(image: Image.Image, height, width):
|
115 |
image = np.array(image)
|
116 |
# alpha = image[..., 3] > 0
|
117 |
-
alpha = image
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
H, W = alpha.shape
|
119 |
# get the bounding box of alpha
|
120 |
y, x = np.where(alpha)
|
|
|
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)
|