diff --git a/rembg/bg.py b/rembg/bg.py index b5ce82a3..9c407d54 100644 --- a/rembg/bg.py +++ b/rembg/bg.py @@ -74,9 +74,8 @@ def alpha_matting_cutout( def naive_cutout(img: PILImage, mask: PILImage) -> PILImage: - empty = Image.new("RGBA", (img.size), 0) - cutout = Image.composite(img, empty, mask) - return cutout + img.putalpha(mask) + return img def get_concat_v_multi(imgs: List[PILImage]) -> PILImage: diff --git a/tests/results/anime-girl-1.isnet-anime.png b/tests/results/anime-girl-1.isnet-anime.png index 8ed53b8c..3a240bbc 100644 Binary files a/tests/results/anime-girl-1.isnet-anime.png and b/tests/results/anime-girl-1.isnet-anime.png differ diff --git a/tests/results/anime-girl-1.isnet-general-use.png b/tests/results/anime-girl-1.isnet-general-use.png index 1f573024..8e954c9f 100644 Binary files a/tests/results/anime-girl-1.isnet-general-use.png and b/tests/results/anime-girl-1.isnet-general-use.png differ diff --git a/tests/results/anime-girl-1.sam.png b/tests/results/anime-girl-1.sam.png index daf576f0..9d3c9c01 100644 Binary files a/tests/results/anime-girl-1.sam.png and b/tests/results/anime-girl-1.sam.png differ diff --git a/tests/results/anime-girl-1.silueta.png b/tests/results/anime-girl-1.silueta.png index 199c3a34..a6f97b08 100644 Binary files a/tests/results/anime-girl-1.silueta.png and b/tests/results/anime-girl-1.silueta.png differ diff --git a/tests/results/anime-girl-1.u2net.png b/tests/results/anime-girl-1.u2net.png index fc48847e..6be6bf28 100644 Binary files a/tests/results/anime-girl-1.u2net.png and b/tests/results/anime-girl-1.u2net.png differ diff --git a/tests/results/anime-girl-1.u2net_cloth_seg.png b/tests/results/anime-girl-1.u2net_cloth_seg.png index 2dbd1ab8..f3aaca5a 100644 Binary files a/tests/results/anime-girl-1.u2net_cloth_seg.png and b/tests/results/anime-girl-1.u2net_cloth_seg.png differ diff --git a/tests/results/anime-girl-1.u2net_human_seg.png b/tests/results/anime-girl-1.u2net_human_seg.png index 6ca89159..44c32d6c 100644 Binary files a/tests/results/anime-girl-1.u2net_human_seg.png and b/tests/results/anime-girl-1.u2net_human_seg.png differ diff --git a/tests/results/anime-girl-1.u2netp.png b/tests/results/anime-girl-1.u2netp.png index 4b20f056..433327f0 100644 Binary files a/tests/results/anime-girl-1.u2netp.png and b/tests/results/anime-girl-1.u2netp.png differ diff --git a/tests/results/car-1.isnet-anime.png b/tests/results/car-1.isnet-anime.png index cdb19da5..51d1069e 100644 Binary files a/tests/results/car-1.isnet-anime.png and b/tests/results/car-1.isnet-anime.png differ diff --git a/tests/results/car-1.isnet-general-use.png b/tests/results/car-1.isnet-general-use.png index dba386dd..fce55979 100644 Binary files a/tests/results/car-1.isnet-general-use.png and b/tests/results/car-1.isnet-general-use.png differ diff --git a/tests/results/car-1.sam.png b/tests/results/car-1.sam.png index 2250b06d..36dd8c1f 100644 Binary files a/tests/results/car-1.sam.png and b/tests/results/car-1.sam.png differ diff --git a/tests/results/car-1.silueta.png b/tests/results/car-1.silueta.png index 286cfcff..52beb7cb 100644 Binary files a/tests/results/car-1.silueta.png and b/tests/results/car-1.silueta.png differ diff --git a/tests/results/car-1.u2net.png b/tests/results/car-1.u2net.png index d8f9115e..d29161e8 100644 Binary files a/tests/results/car-1.u2net.png and b/tests/results/car-1.u2net.png differ diff --git a/tests/results/car-1.u2net_cloth_seg.png b/tests/results/car-1.u2net_cloth_seg.png index e4ae7612..1fc035d5 100644 Binary files a/tests/results/car-1.u2net_cloth_seg.png and b/tests/results/car-1.u2net_cloth_seg.png differ diff --git a/tests/results/car-1.u2net_human_seg.png b/tests/results/car-1.u2net_human_seg.png index 597e8853..b1a627de 100644 Binary files a/tests/results/car-1.u2net_human_seg.png and b/tests/results/car-1.u2net_human_seg.png differ diff --git a/tests/results/car-1.u2netp.png b/tests/results/car-1.u2netp.png index 8eeaa7b8..32ae7f62 100644 Binary files a/tests/results/car-1.u2netp.png and b/tests/results/car-1.u2netp.png differ diff --git a/tests/results/cloth-1.isnet-anime.png b/tests/results/cloth-1.isnet-anime.png index 7c4c65d3..bba3c79f 100644 Binary files a/tests/results/cloth-1.isnet-anime.png and b/tests/results/cloth-1.isnet-anime.png differ diff --git a/tests/results/cloth-1.isnet-general-use.png b/tests/results/cloth-1.isnet-general-use.png index 9f141ea9..e38280cd 100644 Binary files a/tests/results/cloth-1.isnet-general-use.png and b/tests/results/cloth-1.isnet-general-use.png differ diff --git a/tests/results/cloth-1.sam.png b/tests/results/cloth-1.sam.png index 2ef9037c..a0900edf 100644 Binary files a/tests/results/cloth-1.sam.png and b/tests/results/cloth-1.sam.png differ diff --git a/tests/results/cloth-1.silueta.png b/tests/results/cloth-1.silueta.png index 78af7569..d8a0993b 100644 Binary files a/tests/results/cloth-1.silueta.png and b/tests/results/cloth-1.silueta.png differ diff --git a/tests/results/cloth-1.u2net.png b/tests/results/cloth-1.u2net.png index 8743fcd4..5f4cdaa0 100644 Binary files a/tests/results/cloth-1.u2net.png and b/tests/results/cloth-1.u2net.png differ diff --git a/tests/results/cloth-1.u2net_cloth_seg.png b/tests/results/cloth-1.u2net_cloth_seg.png index 63ab692a..d7822cca 100644 Binary files a/tests/results/cloth-1.u2net_cloth_seg.png and b/tests/results/cloth-1.u2net_cloth_seg.png differ diff --git a/tests/results/cloth-1.u2net_human_seg.png b/tests/results/cloth-1.u2net_human_seg.png index 62ccc79e..45870620 100644 Binary files a/tests/results/cloth-1.u2net_human_seg.png and b/tests/results/cloth-1.u2net_human_seg.png differ diff --git a/tests/results/cloth-1.u2netp.png b/tests/results/cloth-1.u2netp.png index c2fce725..287c275b 100644 Binary files a/tests/results/cloth-1.u2netp.png and b/tests/results/cloth-1.u2netp.png differ diff --git a/tests/test_remove.py b/tests/test_remove.py index 79758b63..7f9901c4 100644 --- a/tests/test_remove.py +++ b/tests/test_remove.py @@ -47,7 +47,7 @@ def test_remove(): expected_path = Path(here / "results" / f"{picture}.{model}.png") # Uncomment to update the expected results - # f = open(expected_path, "ab") + # f = open(expected_path, "wb") # f.write(actual) # f.close()