rembg icon indicating copy to clipboard operation
rembg copied to clipboard

[BUG] PNG with transparency is unprocessable with `-a -ae 15` flags

Open RoDmitry opened this issue 3 years ago • 1 comments

PNG with some transparency is unprocessable with -a -ae 15 flags.

Traceback (most recent call last):
  File "/usr/local/bin/rembg", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/rembg/cli.py", line 88, in i
    output.write(remove(input.read(), session=new_session(model), **kwargs))
  File "/usr/local/lib/python3.9/dist-packages/rembg/bg.py", line 116, in remove
    cutout = alpha_matting_cutout(
  File "/usr/local/lib/python3.9/dist-packages/rembg/bg.py", line 52, in alpha_matting_cutout
    alpha = estimate_alpha_cf(img_normalized, trimap_normalized)
  File "/usr/local/lib/python3.9/dist-packages/pymatting/alpha/estimate_alpha_cf.py", line 53, in estimate_alpha_cf
    L = cf_laplacian(image, **laplacian_kwargs, is_known=is_known)
  File "/usr/local/lib/python3.9/dist-packages/pymatting/laplacian/cf_laplacian.py", line 168, in cf_laplacian
    _cf_laplacian(image, epsilon, radius, values, indices, indptr, is_known)
  File "/usr/local/lib/python3.9/dist-packages/pymatting/laplacian/cf_laplacian.py", line 8, in _cf_laplacian
    assert d == 3
AssertionError

Steps to reproduce the behavior:

  1. You have a square PNG image with any transparency in it, named 1.png in /YOUR_DIR.
  2. docker run -it --rm --name rembg_test -w "/app" -v "/YOUR_DIR:/app" danielgatis/rembg i -a -ae 15 1.png 2.png

OS Version: docker on linux

Rembg version: danielgatis/rembg:latest

RoDmitry avatar Jul 12 '22 12:07 RoDmitry

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Aug 12 '22 02:08 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 26 '22 02:08 github-actions[bot]