Skip to content

armgit / rembg

Public Imported from GitHub
0

Rembg is a tool to remove images background

fix: Expected RGB image of shape (?, ?, 3), but image.shape is (?, ?, 4).

goechofb3b9feb728b
diff --git a/rembg/bg.py b/rembg/bg.py
index 60a3045..57ac6b5 100644
--- a/rembg/bg.py
+++ b/rembg/bg.py
@@ -37,6 +37,10 @@ def alpha_matting_cutout(
background_threshold: int,
erode_structure_size: int,
) -> PILImage:
+
+ if img.mode == "RGBA" or img.mode == "CMYK":
+ img = img.convert("RGB")
+
img = np.asarray(img)
mask = np.asarray(mask)