Skip to content

armgit / rembg

Public Imported from GitHub
0

Rembg is a tool to remove images background

Update base.py

PENGUINLIONG112e76d3cd82
diff --git a/rembg/sessions/base.py b/rembg/sessions/base.py
index 470159d..c932ff7 100644
--- a/rembg/sessions/base.py
+++ b/rembg/sessions/base.py
@@ -41,7 +41,7 @@ class BaseSession:
im = img.convert("RGB").resize(size, Image.Resampling.LANCZOS)
im_ary = np.array(im)
- im_ary = im_ary / np.max(im_ary)
+ im_ary = im_ary / max(np.max(im_ary), 1e-6)
tmpImg = np.zeros((im_ary.shape[0], im_ary.shape[1], 3))
tmpImg[:, :, 0] = (im_ary[:, :, 0] - mean[0]) / std[0]