From 92e768c3fa5299d0ee6ef36403016a040182f600 Mon Sep 17 00:00:00 2001 From: Daniel Gatis Date: Mon, 18 Apr 2022 13:13:46 -0300 Subject: [PATCH] fix alpha matting --- rembg/bg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rembg/bg.py b/rembg/bg.py index 6a48f7da..7ff1fa7d 100644 --- a/rembg/bg.py +++ b/rembg/bg.py @@ -90,7 +90,10 @@ def remove( if session is None: session = ort_session("u2net") - mask = predict(session, np.array(img.convert("RGB"))).convert("L") + img = img.convert("RGB") + + mask = predict(session, np.array(img)) + mask = mask.convert("L") mask = mask.resize(img.size, Image.LANCZOS) if only_mask: