From ae46588c7e8ce02deb34ba1c6535872a2012c1d4 Mon Sep 17 00:00:00 2001 From: Daniel Gatis Date: Tue, 6 Jul 2021 00:56:31 -0300 Subject: [PATCH] fix issue 116 --- setup.py | 2 +- src/rembg/bg.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index cd333ea..40c3c35 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ with open("requirements.txt") as f: setup( name="rembg", - version="1.0.26", + version="1.0.27", description="Remove image background", long_description=long_description, long_description_content_type="text/markdown", diff --git a/src/rembg/bg.py b/src/rembg/bg.py index 2177ddf..5f28cf6 100644 --- a/src/rembg/bg.py +++ b/src/rembg/bg.py @@ -92,14 +92,17 @@ def remove( mask = detect.predict(model, np.array(img)).convert("L") if alpha_matting: - cutout = alpha_matting_cutout( - img, - mask, - alpha_matting_foreground_threshold, - alpha_matting_background_threshold, - alpha_matting_erode_structure_size, - alpha_matting_base_size, - ) + try: + cutout = alpha_matting_cutout( + img, + mask, + alpha_matting_foreground_threshold, + alpha_matting_background_threshold, + alpha_matting_erode_structure_size, + alpha_matting_base_size, + ) + except: + cutout = naive_cutout(img, mask) else: cutout = naive_cutout(img, mask)