GithubHelp home page GithubHelp logo

danielgatis / rembg Goto Github PK

View Code? Open in Web Editor NEW
14.5K 134.0 1.7K 62.69 MB

Rembg is a tool to remove images background

License: MIT License

Python 95.54% Dockerfile 0.09% PowerShell 0.15% Inno Setup 4.22%
image-processing background-removal python

rembg's Introduction

Rembg

Downloads License Hugging Face Spaces Streamlit App

Rembg is a tool to remove images background.

example car-1 example car-1.out example car-2 example car-2.out example car-3 example car-3.out

example animal-1 example animal-1.out example animal-2 example animal-2.out example animal-3 example animal-3.out

example girl-1 example girl-1.out example girl-2 example girl-2.out example girl-3 example girl-3.out

example anime-girl-1 example anime-girl-1.out example anime-girl-2 example anime-girl-2.out example anime-girl-3 example anime-girl-3.out

If this project has helped you, please consider making a donation.

Sponsor

Unsplash PhotoRoom Remove Background API
https://photoroom.com/api

Fast and accurate background remover API

Requirements

python: >3.7, <3.13

Installation

CPU support:

pip install rembg # for library
pip install rembg[cli] # for library + cli

GPU support:

First of all, you need to check if your system supports the onnxruntime-gpu.

Go to https://onnxruntime.ai and check the installation matrix.

onnxruntime-installation-matrix

If yes, just run:

pip install rembg[gpu] # for library
pip install rembg[gpu,cli] # for library + cli

Usage as a cli

After the installation step you can use rembg just typing rembg in your terminal window.

The rembg command has 4 subcommands, one for each input type:

  • i for files
  • p for folders
  • s for http server
  • b for RGB24 pixel binary stream

You can get help about the main command using:

rembg --help

As well, about all the subcommands using:

rembg <COMMAND> --help

rembg i

Used when input and output are files.

Remove the background from a remote image

curl -s http://input.png | rembg i > output.png

Remove the background from a local file

rembg i path/to/input.png path/to/output.png

Remove the background specifying a model

rembg i -m u2netp path/to/input.png path/to/output.png

Remove the background returning only the mask

rembg i -om path/to/input.png path/to/output.png

Remove the background applying an alpha matting

rembg i -a path/to/input.png path/to/output.png

Passing extras parameters

SAM example

rembg i -m sam -x '{ "sam_prompt": [{"type": "point", "data": [724, 740], "label": 1}] }' examples/plants-1.jpg examples/plants-1.out.png
Custom model example

rembg i -m u2net_custom -x '{"model_path": "~/.u2net/u2net.onnx"}' path/to/input.png path/to/output.png

rembg p

Used when input and output are folders.

Remove the background from all images in a folder

rembg p path/to/input path/to/output

Same as before, but watching for new/changed files to process

rembg p -w path/to/input path/to/output

rembg s

Used to start http server.

rembg s --host 0.0.0.0 --port 7000 --log_level info

To see the complete endpoints documentation, go to: http://localhost:7000/api.

Remove the background from an image url

curl -s "http://localhost:7000/api/remove?url=http://input.png" -o output.png

Remove the background from an uploaded image

curl -s -F file=@/path/to/input.jpg "http://localhost:7000/api/remove"  -o output.png

rembg b

Process a sequence of RGB24 images from stdin. This is intended to be used with another program, such as FFMPEG, that outputs RGB24 pixel data to stdout, which is piped into the stdin of this program, although nothing prevents you from manually typing in images at stdin.

rembg b image_width image_height -o output_specifier

Arguments:

  • image_width : width of input image(s)
  • image_height : height of input image(s)
  • output_specifier: printf-style specifier for output filenames, for example if output-%03u.png, then output files will be named output-000.png, output-001.png, output-002.png, etc. Output files will be saved in PNG format regardless of the extension specified. You can omit it to write results to stdout.

Example usage with FFMPEG:

ffmpeg -i input.mp4 -ss 10 -an -f rawvideo -pix_fmt rgb24 pipe:1 | rembg b 1280 720 -o folder/output-%03u.png

The width and height values must match the dimension of output images from FFMPEG. Note for FFMPEG, the "-an -f rawvideo -pix_fmt rgb24 pipe:1" part is required for the whole thing to work.

Usage as a library

Input and output as bytes

from rembg import remove

input_path = 'input.png'
output_path = 'output.png'

with open(input_path, 'rb') as i:
    with open(output_path, 'wb') as o:
        input = i.read()
        output = remove(input)
        o.write(output)

Input and output as a PIL image

from rembg import remove
from PIL import Image

input_path = 'input.png'
output_path = 'output.png'

input = Image.open(input_path)
output = remove(input)
output.save(output_path)

Input and output as a numpy array

from rembg import remove
import cv2

input_path = 'input.png'
output_path = 'output.png'

input = cv2.imread(input_path)
output = remove(input)
cv2.imwrite(output_path, output)

How to iterate over files in a performatic way

from pathlib import Path
from rembg import remove, new_session

session = new_session()

for file in Path('path/to/folder').glob('*.png'):
    input_path = str(file)
    output_path = str(file.parent / (file.stem + ".out.png"))

    with open(input_path, 'rb') as i:
        with open(output_path, 'wb') as o:
            input = i.read()
            output = remove(input, session=session)
            o.write(output)

To see a full list of examples on how to use rembg, go to the examples page.

Usage as a docker

Just replace the rembg command for docker run danielgatis/rembg.

Try this:

docker run -v path/to/input:/rembg danielgatis/rembg i input.png path/to/output/output.png

Models

All models are downloaded and saved in the user home folder in the .u2net directory.

The available models are:

  • u2net (download, source): A pre-trained model for general use cases.
  • u2netp (download, source): A lightweight version of u2net model.
  • u2net_human_seg (download, source): A pre-trained model for human segmentation.
  • u2net_cloth_seg (download, source): A pre-trained model for Cloths Parsing from human portrait. Here clothes are parsed into 3 category: Upper body, Lower body and Full body.
  • silueta (download, source): Same as u2net but the size is reduced to 43Mb.
  • isnet-general-use (download, source): A new pre-trained model for general use cases.
  • isnet-anime (download, source): A high-accuracy segmentation for anime character.
  • sam (download encoder, download decoder, source): A pre-trained model for any use cases.

How to train your own model

If You need more fine tuned models try this: #193 (comment)

Some video tutorials

References

FAQ

When will this library provide support for Python version 3.xx?

This library directly depends on the onnxruntime library. Therefore, we can only update the Python version when onnxruntime provides support for that specific version.

Buy me a coffee

Liked some of my work? Buy me a coffee (or more likely a beer)

Buy Me A Coffee

Star History

Star History Chart

License

Copyright (c) 2020-present Daniel Gatis

Licensed under MIT License

rembg's People

Contributors

0xflotus avatar aashrut avatar aleksandar1932 avatar alexey-pelykh avatar artemmolotov avatar bendangnuksung avatar carlogrisetti avatar carojasdu avatar cclauss avatar coskunyceyhun avatar danielgatis avatar deltazero-cz avatar dmitrykazakevich avatar easterlings avatar flippchen avatar hanruihua avatar iory avatar jangop avatar jaric avatar kenjiedec avatar kianmeng avatar lajcisvk avatar madmaxinfinity avatar mcyba avatar nagy avatar nett00n avatar rcrvano avatar repushko avatar runa91 avatar samiede avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rembg's Issues

Running setup.py bdist_wheel for llvmlite ... error

Hey,
I really like your project! It really saved me a lot of time (and money)
But now I want to install it on a Virtual Machine on Digital Ocean, a Debian 10 one to more exact.
And it doesn't want to install:

Building wheels for collected packages: rembg, numba, llvmlite
  Running setup.py bdist_wheel for rembg ... done
  Stored in directory: /root/.cache/pip/wheels/d5/ad/72/a29715e07848809bb37bf068f7540983975e7941fbd4c1ea34
  Running setup.py bdist_wheel for numba ... done
  Stored in directory: /root/.cache/pip/wheels/cd/cd/8c/314cbe49cd8bb876f251763442807db9d55968d1f44cb20013
  Running setup.py bdist_wheel for llvmlite ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-pekaldf3/llvmlite/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-u2vc646x --python-tag cp37:
  running bdist_wheel
  /usr/bin/python3 /tmp/pip-install-pekaldf3/llvmlite/ffi/build.py
  LLVM version... Traceback (most recent call last):
    File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 105, in main_posix
      out = subprocess.check_output([llvm_config, '--version'])
    File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
      **kwargs).stdout
    File "/usr/lib/python3.7/subprocess.py", line 472, in run
      with Popen(*popenargs, **kwargs) as process:
    File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
      restore_signals, start_new_session)
    File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config': 'llvm-config'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 191, in <module>
      main()
    File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 181, in main
      main_posix('linux', '.so')
    File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 108, in main_posix
      "to the path for llvm-config" % (llvm_config,))
  RuntimeError: llvm-config failed executing, please point LLVM_CONFIG to the path for llvm-config
  error: command '/usr/bin/python3' failed with exit status 1

  ----------------------------------------
  Failed building wheel for llvmlite
  Running setup.py clean for llvmlite
Successfully built rembg numba
Failed to build llvmlite
Installing collected packages: llvmlite, numba, pymatting, rembg
  Running setup.py install for llvmlite ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-pekaldf3/llvmlite/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-i02sowqg/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    got version from file /tmp/pip-install-pekaldf3/llvmlite/llvmlite/_version.py {'version': '0.34.0', 'full': 'c5889c9e98c6b19d5d85ebdd982d64a03931f8e2'}
    running build_ext
    /usr/bin/python3 /tmp/pip-install-pekaldf3/llvmlite/ffi/build.py
    LLVM version... Traceback (most recent call last):
      File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 105, in main_posix
        out = subprocess.check_output([llvm_config, '--version'])
      File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
        **kwargs).stdout
      File "/usr/lib/python3.7/subprocess.py", line 472, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
        restore_signals, start_new_session)
      File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config': 'llvm-config'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 191, in <module>
        main()
      File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 181, in main
        main_posix('linux', '.so')
      File "/tmp/pip-install-pekaldf3/llvmlite/ffi/build.py", line 108, in main_posix
        "to the path for llvm-config" % (llvm_config,))
    RuntimeError: llvm-config failed executing, please point LLVM_CONFIG to the path for llvm-config
    error: command '/usr/bin/python3' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-pekaldf3/llvmlite/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-i02sowqg/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-pekaldf3/llvmlite/

Can anyone help with this? I got a lot of obscure errors I was able to fix (as an example Memory Errors due to torch) but I couldn't fix that one (yet)

Error ModuleNotFoundError: No module named 'pymatting_aot.aot'

Hello,
I have centos 8 server.

This is the error after running the command
rembg -o input_image output_image

Failed to import ahead-of-time-compiled modules. This is expected on first import.
Compiling modules and trying again (this might take a minute).
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pymatting_aot/cc.py", line 21, in
import pymatting_aot.aot
ModuleNotFoundError: No module named 'pymatting_aot.aot'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/rembg", line 5, in
from rembg.cmd.cli import main
File "/usr/local/lib/python3.8/site-packages/rembg/cmd/cli.py", line 7, in
from ..bg import remove
File "/usr/local/lib/python3.8/site-packages/rembg/bg.py", line 6, in
from pymatting.alpha.estimate_alpha_cf import estimate_alpha_cf
File "/usr/local/lib/python3.8/site-packages/pymatting/init.py", line 2, in
import pymatting_aot.cc
File "/usr/local/lib/python3.8/site-packages/pymatting_aot/cc.py", line 28, in
compile_modules()
File "/usr/local/lib/python3.8/site-packages/pymatting_aot/cc.py", line 16, in compile_modules
cc.compile()
File "/usr/local/lib64/python3.8/site-packages/numba/core/compiler_lock.py", line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File "/usr/local/lib64/python3.8/site-packages/numba/pycc/cc.py", line 217, in compile
objects += self._compile_mixins(build_dir)
File "/usr/local/lib64/python3.8/site-packages/numba/pycc/cc.py", line 187, in _compile_mixins
objects = self._toolchain.compile_objects(sources, build_dir,
File "/usr/local/lib64/python3.8/site-packages/numba/pycc/platform.py", line 137, in compile_objects
objects = self._compiler.compile(sources,
File "/usr/local/lib64/python3.8/site-packages/numpy/distutils/ccompiler.py", line 90, in
m = lambda self, *args, **kw: func(self, *args, **kw)
File "/usr/local/lib64/python3.8/site-packages/numpy/distutils/ccompiler.py", line 356, in CCompiler_compile
pool.map(single_compile, build_items)
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 768, in get
raise self._value
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/lib64/python3.8/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/usr/local/lib64/python3.8/site-packages/numpy/distutils/ccompiler.py", line 321, in single_compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/usr/local/lib64/python3.8/site-packages/numpy/distutils/ccompiler.py", line 90, in
m = lambda self, *args, **kw: func(self, *args, **kw)
File "/usr/local/lib64/python3.8/site-packages/numpy/distutils/unixccompiler.py", line 54, in UnixCCompiler__compile
raise CompileError(msg)
distutils.errors.CompileError: Command "gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYCC_MODULE_NAME=aot -DPYCC_USE_NRT=1 -I/usr/include/python3.8 -I/usr/local/lib64/python3.8/site-packages/numpy/core/include -c /usr/local/lib64/python3.8/site-packages/numba/cext/utils.c -o /tmp/pycc-build-aot-gz0f8q5m/usr/local/lib64/python3.8/site-packages/numba/cext/utils.o" failed with exit status 1

This is the command I have used to install rembg

python3.8 -m pip install --upgrade pip

[root@ ]# python3.8 -m pip install rembg

Processing /root/.cache/pip/wheels/c4/52/be/f93ed10eb3209e691a9226d0ba337172ef19e38a0014892198/rembg-1.0.15-cp38-none-any.whl
Requirement already satisfied: pillow==8.0.1 in /usr/local/lib64/python3.8/site-packages (from rembg) (8.0.1)
Requirement already satisfied: numpy==1.19.4 in /usr/local/lib64/python3.8/site-packages (from rembg) (1.19.4)
Requirement already satisfied: requests==2.24.0 in /usr/local/lib/python3.8/site-packages (from rembg) (2.24.0)
Requirement already satisfied: scipy==1.5.4 in /usr/local/lib64/python3.8/site-packages (from rembg) (1.5.4)
Requirement already satisfied: scikit-image==0.17.2 in /usr/local/lib64/python3.8/site-packages (from rembg) (0.17.2)
Requirement already satisfied: waitress==1.4.4 in /usr/local/lib/python3.8/site-packages (from rembg) (1.4.4)
Requirement already satisfied: pymatting==1.1.1 in /usr/local/lib/python3.8/site-packages (from rembg) (1.1.1)
Requirement already satisfied: tqdm==4.51.0 in /usr/local/lib/python3.8/site-packages (from rembg) (4.51.0)
Requirement already satisfied: flask==1.1.2 in /usr/local/lib/python3.8/site-packages (from rembg) (1.1.2)
Requirement already satisfied: torchvision==0.8.1 in /usr/local/lib64/python3.8/site-packages (from rembg) (0.8.1)
Requirement already satisfied: torch==1.7.0 in /usr/local/lib64/python3.8/site-packages (from rembg) (1.7.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.8/site-packages (from requests==2.24.0->rembg) (1.25.11)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/site-packages (from requests==2.24.0->rembg) (2020.11.8)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.8/site-packages (from requests==2.24.0->rembg) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/site-packages (from requests==2.24.0->rembg) (2.10)
Requirement already satisfied: tifffile>=2019.7.26 in /usr/local/lib/python3.8/site-packages (from scikit-image==0.17.2->rembg) (2020.10.1)
Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in /usr/local/lib64/python3.8/site-packages (from scikit-image==0.17.2->rembg) (3.3.3)
Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.8/site-packages (from scikit-image==0.17.2->rembg) (2.5)
Requirement already satisfied: imageio>=2.3.0 in /usr/local/lib/python3.8/site-packages (from scikit-image==0.17.2->rembg) (2.9.0)
Requirement already satisfied: PyWavelets>=1.1.1 in /usr/local/lib64/python3.8/site-packages (from scikit-image==0.17.2->rembg) (1.1.1)
Requirement already satisfied: numba!=0.49.0 in /usr/local/lib64/python3.8/site-packages (from pymatting==1.1.1->rembg) (0.51.2)
Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib/python3.8/site-packages (from flask==1.1.2->rembg) (2.11.2)
Requirement already satisfied: click>=5.1 in /usr/local/lib/python3.8/site-packages (from flask==1.1.2->rembg) (7.1.2)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python3.8/site-packages (from flask==1.1.2->rembg) (1.1.0)
Requirement already satisfied: Werkzeug>=0.15 in /usr/local/lib/python3.8/site-packages (from flask==1.1.2->rembg) (1.0.1)
Requirement already satisfied: dataclasses in /usr/local/lib/python3.8/site-packages (from torch==1.7.0->rembg) (0.6)
Requirement already satisfied: future in /usr/local/lib/python3.8/site-packages (from torch==1.7.0->rembg) (0.18.2)
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.8/site-packages (from torch==1.7.0->rembg) (3.7.4.3)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib64/python3.8/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.17.2->rembg) (1.3.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/local/lib/python3.8/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.17.2->rembg) (2.4.7)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.8/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.17.2->rembg) (2.8.1)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.8/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.17.2->rembg) (0.10.0)
Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.8/site-packages (from networkx>=2.0->scikit-image==0.17.2->rembg) (4.4.2)
Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /usr/local/lib64/python3.8/site-packages (from numba!=0.49.0->pymatting==1.1.1->rembg) (0.34.0)
Requirement already satisfied: setuptools in /usr/lib/python3.8/site-packages (from numba!=0.49.0->pymatting==1.1.1->rembg) (41.6.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib64/python3.8/site-packages (from Jinja2>=2.10.1->flask==1.1.2->rembg) (1.1.1)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.8/site-packages (from python-dateutil>=2.1->matplotlib!=3.0.0,>=2.0.0->scikit-image==0.17.2->rembg) (1.15.0)
Installing collected packages: rembg
Successfully installed rembg-1.0.15

Please suggest

Add config option for default model

Hey,
I really like your project! It really helped me a lot.
But I have a small issue: I am currently building a Docker Container with a FastAPI Server for rembg, to deploy it via Kubernetes and get a pretty scalable and cheap Background Removal as a Service.
I will release that later, but I have a performance issue:
In bg.py you automatically load both models, but I will only use the u2netp one.
I want to speed up the API as fast as I can, and therefore there should be a config option (there is no config, yet?) to only load the needed model.
That will be a difficult task tho, I don't really know how to implement it since this module is not a class and I can't add parameters to it or anything.

Greetings,
Altay@Dorfmeyster

Doing this for videos?

Hi!
Thank you for this work. I am working on videos and I extracted all frames and removed background for each frame.

This understandably takes a long time.

Is there a way to fasten this process? Would running os.sys calls on multiple threads help? Are there other techniques that could be used.

Expected maxsize to be an integer or None

Hi,
I tried following image and got error.

curl -s https://i.pinimg.com/564x/b0/f2/50/b0f250c4f155a12e916d7ccd46f63bcb.jpg | rembg > output.png

Traceback (most recent call last):
  File "/Users/nowhereman/.pyenv/versions/pydata/bin/rembg", line 6, in <module>
    from rembg.cmd.cli import main
  File "/Users/nowhereman/.pyenv/versions/3.7.3/envs/pydata/lib/python3.7/site-packages/rembg/cmd/cli.py", line 7, in <module>
    from ..bg import remove
  File "/Users/nowhereman/.pyenv/versions/3.7.3/envs/pydata/lib/python3.7/site-packages/rembg/bg.py", line 67, in <module>
    @functools.lru_cache
  File "/Users/nowhereman/.pyenv/versions/3.7.3/lib/python3.7/functools.py", line 477, in lru_cache
    raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None

Any comment?

fix typo

Hello

I got found one miss typo at README.md.

<input type="submi"t value="upload"/>

it would be

<input type="submit" value="upload"/>

Erasing main objects

Hi

In some internet services the result appears without erasing main objects.

Is there a way to remove background without erasing main objects?

ORIGINAL
guitarra

GENERATED
guitarra2

GENERATED ANOTHER SERVICE
guitarra4

Upgrade torchvision version

I got an error for installing rembg

ERROR: Could not find a version that satisfies the requirement torchvision==0.8.1 (from rembg) (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3, 0.5.0)
ERROR: No matching distribution found for torchvision==0.8.1 (from rembg)

Preparing wheel metadata ERROR: Command errored out with exit status 1:

I got this error while installing the program. Please kindly help.

Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
 command: 'c:\users\phearun\appdata\local\programs\python\python39\python.exe' 'c:\users\phearun\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\Phearun\AppData\Local\Temp\tmpdhlvhxvg'
     cwd: C:\Users\Phearun\AppData\Local\Temp\pip-install-nacjzc_u\scipy
Complete output (195 lines):
setup.py:460: UserWarning: Unrecognized setuptools command ('dist_info --egg-base C:\Users\Phearun\AppData\Local\Temp\pip-modern-metadata-e08wg4a2'), proceeding with generating Cython sources and expanding templates
  warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
Running from SciPy source directory.
lapack_opt_info:
lapack_mkl_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries mkl_rt not found in ['c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\lib', 'C:\\', 'c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\libs']
  NOT AVAILABLE

openblas_lapack_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries openblas not found in ['c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\lib', 'C:\\', 'c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\libs']
get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Could not locate executable gfortran
Could not locate executable f95
customize G95FCompiler
Could not locate executable g95
customize IntelEM64VisualFCompiler
customize IntelEM64TFCompiler
Could not locate executable efort
Could not locate executable efc
customize PGroupFlangCompiler
Could not locate executable flang
don't know how to compile Fortran code on platform 'nt'
  NOT AVAILABLE

openblas_clapack_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries openblas,lapack not found in ['c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\lib', 'C:\\', 'c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\libs']
  NOT AVAILABLE

flame_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries flame not found in ['c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\lib', 'C:\\', 'c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\libs']
  NOT AVAILABLE

atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
  NOT AVAILABLE

atlas_3_10_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
<class 'numpy.distutils.system_info.atlas_3_10_info'>
  NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
<class 'numpy.distutils.system_info.atlas_threads_info'>
  NOT AVAILABLE

atlas_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in c:\users\phearun\appdata\local\programs\python\python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in c:\users\phearun\appdata\local\programs\python\python39\libs
<class 'numpy.distutils.system_info.atlas_info'>
  NOT AVAILABLE

accelerate_info:
  NOT AVAILABLE

lapack_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack not found in ['c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\lib', 'C:\\', 'c:\\users\\phearun\\appdata\\local\\programs\\python\\python39\\libs']
  NOT AVAILABLE

C:\Users\Phearun\AppData\Local\Temp\pip-build-env-6gv_wa52\overlay\Lib\site-packages\numpy\distutils\system_info.py:1712: UserWarning:
    Lapack (http://www.netlib.org/lapack/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [lapack]) or by setting
    the LAPACK environment variable.
  if getattr(self, '_calc_info_{}'.format(lapack))():
lapack_src_info:
  NOT AVAILABLE

C:\Users\Phearun\AppData\Local\Temp\pip-build-env-6gv_wa52\overlay\Lib\site-packages\numpy\distutils\system_info.py:1712: UserWarning:
    Lapack (http://www.netlib.org/lapack/) sources not found.
    Directories to search for the sources can be specified in the
    numpy/distutils/site.cfg file (section [lapack_src]) or by setting
    the LAPACK_SRC environment variable.
  if getattr(self, '_calc_info_{}'.format(lapack))():
  NOT AVAILABLE

Traceback (most recent call last):
  File "c:\users\phearun\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <module>
    main()
  File "c:\users\phearun\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "c:\users\phearun\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 133, in prepare_metadata_for_build_wheel
    return hook(metadata_directory, config_settings)
  File "C:\Users\Phearun\AppData\Local\Temp\pip-build-env-6gv_wa52\overlay\Lib\site-packages\setuptools\build_meta.py", line 161, in prepare_metadata_for_build_wheel
    self.run_setup()
  File "C:\Users\Phearun\AppData\Local\Temp\pip-build-env-6gv_wa52\overlay\Lib\site-packages\setuptools\build_meta.py", line 253, in run_setup
    super(_BuildMetaLegacyBackend,
  File "C:\Users\Phearun\AppData\Local\Temp\pip-build-env-6gv_wa52\overlay\Lib\site-packages\setuptools\build_meta.py", line 145, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 583, in <module>
    setup_package()
  File "setup.py", line 579, in setup_package
    setup(**metadata)
  File "C:\Users\Phearun\AppData\Local\Temp\pip-build-env-6gv_wa52\overlay\Lib\site-packages\numpy\distutils\core.py", line 137, in setup
    config = configuration()
  File "setup.py", line 477, in configuration
    raise NotFoundError(msg)
numpy.distutils.system_info.NotFoundError: No lapack/blas resources found.
----------------------------------------

ERROR: Command errored out with exit status 1: 'c:\users\phearun\appdata\local\programs\python\python39\python.exe' 'c:\users\phearun\appdata\local\programs\python\python39\lib\site-packages\pip_vendor\pep517_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\Phearun\AppData\Local\Temp\tmpdhlvhxvg' Check the logs for full command output.

Older versions (for <= python 3.7) not working

My initial codebase is written for python 3.7 so I was using version 1.0.13 of the rembg package for a long time.
Two days ago I started receiving that error: _pickle.UnpicklingError: invalid load key, '<'.

image

I now can't even use older versions. Does anybody have a solution in mind?

Blurred

I have 3000x5000px images and the background removal works more or less nicely. However, the resulting image is blurred (the dimensions are the same as the original). Is there a parameter to address this?
additionally, would it be possible to just output the alpha channel?

exec from a php file

Hello,

Thank you so much for this great tool.
I have a php website using CodeIgniter.

When I execute the code below from a php file at the root of my website, it"s working fine.
When I execute it in the codeIgniter 'application' folder (what I need), it doesn't work. Any file is returned.

I have tried with python as well

$rembgpy = '/my_path/app.py';
$in = '/my_path/lanterne.jpg';
$out = '/mypath/new_lanterne.png';

exec("rembg -o '$out' '$in'");

exec("cat '$in' | python3.6 '$rembgpy' > '$out' ");

Do you have any idea ? (In codeIgniter, python is working for other python program)

Thank you very much
Aude

torch error

ERROR: Could not find a version that satisfies the requirement torch==1.6.0 (from rembg) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.6.0 (from rembg)

I also get this error when I try to install torch.

  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/[email protected]/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"'; __file__='"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-wheel-fdh_s1h4
       cwd: /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/
  Complete output (30 lines):
  running bdist_wheel
  running build
  running build_deps
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py", line 225, in <module>
      setup(name="torch", version="0.1.2.post2",
    File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 290, in run
      self.run_command('build')
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py", line 51, in run
      from tools.nnwrap import generate_wrappers as generate_nn_wrappers
  ModuleNotFoundError: No module named 'tools.nnwrap'
  ----------------------------------------
  ERROR: Failed building wheel for torch
  Running setup.py clean for torch
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/[email protected]/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"'; __file__='"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
       cwd: /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch
  Complete output (2 lines):
  running clean
  error: [Errno 2] No such file or directory: '.gitignore'
  ----------------------------------------
  ERROR: Failed cleaning build dir for torch
Failed to build torch
Installing collected packages: torch
    Running setup.py install for torch ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/[email protected]/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"'; __file__='"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-record-cp5gwhp7/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/torch
         cwd: /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/
    Complete output (23 lines):
    running install
    running build_deps
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py", line 225, in <module>
        setup(name="torch", version="0.1.2.post2",
      File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py", line 99, in run
        self.run_command('build_deps')
      File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/[email protected]/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py", line 51, in run
        from tools.nnwrap import generate_wrappers as generate_nn_wrappers
    ModuleNotFoundError: No module named 'tools.nnwrap'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/[email protected]/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"'; __file__='"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-jn4ttpcw/torch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-record-cp5gwhp7/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/torch Check the logs for full command output.

any way to increase accuracy?

hey there first off thanks for putting this together. I'm trying to use it to remove the background of product photos of shoes and I need them to be remove dot bee gee level accurate... any way to 'increase the power'?

cheers

Error when run test code

I run cli "rembg -o out.png test.png", console show this error
Traceback (most recent call last):
File "/home/tony/PycharmProjects/rem/venv/bin/rembg", line 8, in
sys.exit(main())
File "/home/tony/PycharmProjects/rem/venv/lib/python3.8/site-packages/rembg/cmd/cli.py", line 118, in main
remove(
File "/home/tony/PycharmProjects/rem/venv/lib/python3.8/site-packages/rembg/bg.py", line 84, in remove
img = Image.open(io.BytesIO(data)).convert("RGB")
File "/home/tony/PycharmProjects/rem/venv/lib/python3.8/site-packages/PIL/Image.py", line 2943, in open
raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f50f7b4eb30>

Please Suggestion. thanks

Running on a GPU

Hello Daniel,

This project works great out of the box. Thanks for sharing.

I'm working on a hobby project but I realized it works slow on CPU (30 sec for a 1200x1800 image).

What I wonder is, if I use a server with a GPU support (e.g. google compute engine), how much the result will change.
I saw this line so I think it will use CUDA if it's available. Is this correct?

The last question is, how much performance boost I will be able to see? 2x or 3x maybe?
Thanks,
Cihad

why docker image size is very big

โžœ  ~ docker pull danielgatis/rembg
Using default tag: latest
latest: Pulling from danielgatis/rembg
6a5697faee43: Pull complete 
ba13d3bc422b: Pull complete 
a254829d9e55: Pull complete 
f853e5702a31: Pull complete 
29cfce72a460: Pull complete 
4bb689f629d3: Pull complete 
302d6ee79e94: Downloading [=========>                                         ]    273MB/1.501GB
fe1233ff1aac: Downloading [=========>                                         ]  233.1MB/1.236GB
e8e3fb0eda20: Download complete 
5bbf6ed80873: Downloading [>                                                  ]   29.4MB/1.816GB

Problem with some frames

Is there a way to adjust this to use previous frameif it did that frame nice as reference? Is doing nice with most of the frames but in "random" sequencesdo it wrong. Here an example.

Thank you so much for the work i'm learning a lot!

WhatsApp Image 2020-10-07 at 20 38 33
WhatsApp Image 2020-10-07 at 20 39 06

Command errored out with exit status 1

Hi.
I get the following error after the pip install rembg command.

ERROR: Command errored out with exit status 1: command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-0r0l8i3_/scikit-image/setup.py'"'"'; __file__='"'"'/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-0r0l8i3_/scikit-image/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-pip-egg-info-oipq9o0h cwd: /private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-0r0l8i3_/scikit-image/ Complete output (7 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-0r0l8i3_/scikit-image/setup.py", line 234, in <module> 'build_ext': openmp_build_ext(), File "/private/var/folders/d9/3nm1w1td445fj9yfy49kl3300000gn/T/pip-install-0r0l8i3_/scikit-image/setup.py", line 58, in openmp_build_ext from numpy.distutils.command.build_ext import build_ext ModuleNotFoundError: No module named 'numpy' ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Cannot install due to dependencies

I'm hitting an error when installing,

ERROR: Could not find a version that satisfies the requirement torch==1.6.0 (from rembg) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.6.0 (from rembg)

Not working install

Command pip install rembg print error

Collecting rembg
  Could not find a version that satisfies the requirement rembg (from versions: )
No matching distribution found for rembg

How to solve?

Error on MacOsx 10.14.6

Hello,

Thanks for your code, unfortunately I'm unable to make it work on a Mac.

After installing here's the error I encounter:

โœ˜ julien@mbp-ju-2 ๎‚ฐ ~/Desktop ๎‚ฐ rembg -p photos
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/rembg", line 5, in
from rembg.cmd.cli import main
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rembg/cmd/cli.py", line 7, in
from ..bg import remove
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/rembg/bg.py", line 67, in
@functools.lru_cache
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/functools.py", line 477, in lru_cache
raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None

Do you think you can help?

Thanks a lot!

No module named 'pymatting_aot.aot' even after installing python38-devel

yum install python38-devel
Last metadata expiration check: 1:21:27 ago on Sat 26 Dec 2020 03:52:16 AM UTC.
Package python38-devel-3.8.3-3.module_el8.3.0+468+0c52a667.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

rembg -o /root/test/test.png /root/test/test.jpg

Failed to import ahead-of-time-compiled modules. This is expected on first import.
Compiling modules and trying again (this might take a minute).
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/PyMatting-1.1.1-py3.8.egg/pymatting_aot/cc.py", line 21, in
import pymatting_aot.aot
ModuleNotFoundError: No module named 'pymatting_aot.aot'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/rembg", line 11, in
load_entry_point('rembg==1.0.17', 'console_scripts', 'rembg')()
File "/usr/lib/python3.8/site-packages/pkg_resources/init.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.8/site-packages/pkg_resources/init.py", line 2852, in load_entry_point
return ep.load()
File "/usr/lib/python3.8/site-packages/pkg_resources/init.py", line 2443, in load
return self.resolve()
File "/usr/lib/python3.8/site-packages/pkg_resources/init.py", line 2449, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 655, in _load_unlocked
File "", line 618, in _load_backward_compatible
File "", line 259, in load_module
File "/usr/local/lib/python3.8/site-packages/rembg-1.0.17-py3.8.egg/rembg/cmd/cli.py", line 9, in
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 655, in _load_unlocked
File "", line 618, in _load_backward_compatible
File "", line 259, in load_module
File "/usr/local/lib/python3.8/site-packages/rembg-1.0.17-py3.8.egg/rembg/bg.py", line 6, in
File "/usr/local/lib/python3.8/site-packages/PyMatting-1.1.1-py3.8.egg/pymatting/init.py", line 2, in
import pymatting_aot.cc
File "/usr/local/lib/python3.8/site-packages/PyMatting-1.1.1-py3.8.egg/pymatting_aot/cc.py", line 28, in
compile_modules()
File "/usr/local/lib/python3.8/site-packages/PyMatting-1.1.1-py3.8.egg/pymatting_aot/cc.py", line 4, in compile_modules
from numba.pycc import CC
File "/usr/local/lib/python3.8/site-packages/numba-0.52.0-py3.8-linux-x86_64.egg/numba/init.py", line 19, in
from numba.core import config
File "/usr/local/lib/python3.8/site-packages/numba-0.52.0-py3.8-linux-x86_64.egg/numba/core/config.py", line 16, in
import llvmlite.binding as ll
File "/usr/local/lib/python3.8/site-packages/llvmlite-0.35.0-py3.8.egg/llvmlite/binding/init.py", line 4, in
from .dylib import *
File "/usr/local/lib/python3.8/site-packages/llvmlite-0.35.0-py3.8.egg/llvmlite/binding/dylib.py", line 3, in
from llvmlite.binding import ffi
File "/usr/local/lib/python3.8/site-packages/llvmlite-0.35.0-py3.8.egg/llvmlite/binding/ffi.py", line 153, in
raise OSError("Could not load shared object file: {}".format(_lib_name))
OSError: Could not load shared object file: libllvmlite.so

please help

u2net file download failed

first time run rembg command, console error as follows

File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='docs.google.com', port=443): Max retries exceeded with url: /uc?export=download&id=1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f74927be700>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

but I have manual downloaded u2net.pth and u2netp.pth file, put these to /root/.u2net dir,but it does not work, console also error

File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='docs.google.com', port=443): Max retries exceeded with url: /uc?export=download&id=1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f74927be700>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

sudo: rembg๏ผšcommand not found

What a wonderful work!
I am sorry to bother you,but I have a question in "sudo: rembg๏ผšcommand not found".
I have installed rembg,but when I use "rembg -o /home/zc/transformed.png /home/zc/PycharmProjects/pythonProject/modeltest.png",nothing happened.What should I do?How can I operate?

I would very appreciate if you could help me.
Thank you!

Image Border

Hi

In some internet services the result appears without borders.

Is there a way to remove the border from the generated photos?

ORIGINAL
_DSC7085

GENERATED
j2

GENERATED ANOTHER SERVICE
_DSC7085

Cannot install due to dependencies

I am getting this error. Python version is Python 3.7.6 (64-bit).

ERROR: Could not find a version that satisfies the requirement torchvision==0.7.0 (from rembg) (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3, 0.3.0, 0.4.1, 0.5.0)
ERROR: No matching distribution found for torchvision==0.7.0 (from rembg)

Allow to configure path to the model instead of downloading it

How about allowing to rea a pre-downloaded model from disk using some ENV variable that could be configured? I just set up an AWS Lambda using docker image and had to manually update the code to use model from disk because I had some issues with the downloaded models (AWS Lambda has some specific runtime requirements which made it harder to configure with caching option.). What do you think about this use case?

Error on windows

Hello,

I'm unable to make it work on a Windows.

when i exec cmd: rembg -o animal.png animal-3.jpg

Traceback (most recent call last): File "c:\programdata\anaconda3\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\programdata\anaconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\Scripts\rembg.exe\__main__.py", line 7, in <module> File "c:\programdata\anaconda3\lib\site-packages\rembg\cmd\cli.py", line 113, in main remove( File "c:\programdata\anaconda3\lib\site-packages\rembg\bg.py", line 83, in remove model = get_model(model_name) File "c:\programdata\anaconda3\lib\site-packages\rembg\bg.py", line 72, in get_model return detect.load_model(model_name="u2net") File "c:\programdata\anaconda3\lib\site-packages\rembg\u2net\detect.py", line 69, in load_model net.load_state_dict(torch.load(path)) File "c:\programdata\anaconda3\lib\site-packages\torch\serialization.py", line 595, in load return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File "c:\programdata\anaconda3\lib\site-packages\torch\serialization.py", line 781, in _legacy_load deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly) RuntimeError: unexpected EOF, expected 383141 more bytes. The file might be corrupted.

Thanks a lot!

How to achieve quality like remove.bg ?

Hi,
I have installed rembg.
it works nice.
However, remove.bg quality is much better than rembg.
How to achieve quality like remove.bg ?
Is there any such software like remove.bg?
Or, how to improve the quality of rembg?
thanks

rembg can not work with torch 1.7.1?

I installed pytorch 1.7.1 with anaconda.
When I run pip install rembg it said

ERROR: Could not find a version that satisfies the requirement torch==1.7.0 (from rembg) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.7.1)
ERROR: No matching distribution found for torch==1.7.0 (from rembg)

Does rembg need torch exact version 1.7.0?

pip install rembg: ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

 pip install rembg
Collecting rembg
  Using cached rembg-1.0.16.tar.gz (13 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting waitress==1.4.4
  Using cached waitress-1.4.4-py2.py3-none-any.whl (58 kB)
Collecting numpy==1.19.4
  Using cached numpy-1.19.4-cp39-cp39-win_amd64.whl (13.0 MB)
Collecting scikit-image==0.17.2
  Downloading scikit-image-0.17.2.tar.gz (29.8 MB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 29.8 MB 6.8 MB/s
    ERROR: Command errored out with exit status 1:
     command: 'd:\lab\rembg\rembg-env\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\karbo\\AppData\\Local\\Temp\\pip-install-x23l74te\\scikit-image\\setup.py'"'"'; __file__='"'"'C:\\Users\\karbo\\AppData\\Local\\Temp\\pip-install-x23l74te\\scikit-image\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\karbo\AppData\Local\Temp\pip-pip-egg-info-ic2ueh8m'
         cwd: C:\Users\karbo\AppData\Local\Temp\pip-install-x23l74te\scikit-image\
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\karbo\AppData\Local\Temp\pip-install-x23l74te\scikit-image\setup.py", line 234, in <module>
        'build_ext': openmp_build_ext(),
      File "C:\Users\karbo\AppData\Local\Temp\pip-install-x23l74te\scikit-image\setup.py", line 58, in openmp_build_ext
        from numpy.distutils.command.build_ext import build_ext
    ModuleNotFoundError: No module named 'numpy'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.2.3; however, version 20.3.1 is available.
You should consider upgrading via the 'd:\lab\rembg\rembg-env\scripts\python.exe -m pip install --upgrade pip' command.
(rembg-env) PS D:\Lab\rembg\rembg-env> python --version
Python 3.9.0

image

How to train custom models

Hello,

I am complete beginner in realm of Python and Image processing, which btw your work is amazing. Thank you for it.

For most cases your predefined models work great. But in some cases I would like to somehow train/update model which is processing pictures.

I have no idea what is the process.

Can you point me in some direction (step by step tutorial etc.) how to do it?

Again, thank you for your work I โค๏ธ it

Pictures rotating

@danielgatis
Hello, most of my pictures have been rotating to the right (90 degrees) after removing their backgrounds. Does anyone know how to solve this issue? Thanks a lot!
Down below, I attach one of the pictures that I face this issue:

Original:
NIVEA Creme Original

Without background:
NIVEA Creme Rotated

Can I run it without NVIDIA GPU?

Hi there,

I got this error because my PC does not have NVIDIA GPU.
Can I run it without GPU?

rembg -o ~/Downloads/cat.png ~/Downloads/cat.jpg /home/huka/.local/lib/python3.8/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:100.) return torch._C._cuda_getDeviceCount() > 0 Traceback (most recent call last): File "/home/huka/.local/bin/rembg", line 8, in <module> sys.exit(main()) File "/home/huka/.local/lib/python3.8/site-packages/rembg/cmd/cli.py", line 118, in main remove( File "/home/huka/.local/lib/python3.8/site-packages/rembg/bg.py", line 84, in remove img = Image.open(io.BytesIO(data)).convert("RGB") File "/home/huka/.local/lib/python3.8/site-packages/PIL/Image.py", line 2943, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f4ad769ff90>

Many thanks for considering my request.

Best regards,
HungNLK

Unable to install on MacOS Big Sur

Hi , I am trying to install this on MacOS 11.0 (Big sur) it always fails , I have tried different things but it doesn't work
Python version : 3.8.2 , also tried earlier 3.9.0 doesn't work either

Here are my logs:

  Using cached https://files.pythonhosted.org/packages/74/5a/46cbdb14769ed50b1fa16d57e7a34c04d7251afbacdd3589cdfa8ad3503e/rembg-1.0.16.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting scikit-image==0.17.2 (from rembg)
  Using cached https://files.pythonhosted.org/packages/54/fd/c1b0bb8f6f12ef9b4ee8d7674dac82cd482886f8b5cd165631efa533e237/scikit-image-0.17.2.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-v7cbgt59/scikit-image/setup.py'"'"'; __file__='"'"'/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-v7cbgt59/scikit-image/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-v7cbgt59/scikit-image/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-v7cbgt59/scikit-image/setup.py", line 234, in <module>
        'build_ext': openmp_build_ext(),
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-v7cbgt59/scikit-image/setup.py", line 58, in openmp_build_ext
        from numpy.distutils.command.build_ext import build_ext
    ModuleNotFoundError: No module named 'numpy'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
โžœ  rembg-master git:(master) โœ— curl -s http://input.png | rembg > output.png
zsh: command not found: rembg
โžœ  rembg-master git:(master) โœ— pip install --upgrade pip
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages (20.2.4)
โžœ  rembg-master git:(master) โœ— which python
/usr/bin/python
โžœ  rembg-master git:(master) โœ— brew uninstall python
Error: No installed keg or cask with the name "python"
โžœ  rembg-master git:(master) โœ— python --version
Python 2.7.16
โžœ  rembg-master git:(master) โœ— python3 --version
Python 3.8.2
โžœ  rembg-master git:(master) โœ— brew reinstall python
Warning: You are using macOS 11.0.
We do not provide support for this released but not yet supported version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
released but not yet supported version.

==> Downloading https://homebrew.bintray.com/bottles/python%403.9-3.9.0_1.big_
Already downloaded: /Users/nikhilsingh/Library/Caches/Homebrew/downloads/07eae7a7d7ed36eb2ce66e5a1a771df7d9483f58872e38036325d56194554bf8--python@3.9-3.9.0_1.big_sur.bottle.tar.gz
==> Reinstalling [email protected]
==> Pouring [email protected]_1.big_sur.bottle.tar.gz
^C
โžœ  rembg-master git:(master) โœ— brew reinstall [email protected]
Warning: You are using macOS 11.0.
We do not provide support for this released but not yet supported version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
released but not yet supported version.

==> Downloading https://homebrew.bintray.com/bottles/python%403.8-3.8.6_1.big_
Already downloaded: /Users/nikhilsingh/Library/Caches/Homebrew/downloads/bc25badd58f2a016a9cf5f45f7ec5b4beb87cba2f01324fbad4a351696738a24--python@3.8-3.8.6_1.big_sur.bottle.tar.gz
==> Reinstalling [email protected]
==> Pouring [email protected]_1.big_sur.bottle.tar.gz
==> /usr/local/Cellar/[email protected]/3.8.6_1/bin/python3 -s setup.py --no-user-cfg
==> /usr/local/Cellar/[email protected]/3.8.6_1/bin/python3 -s setup.py --no-user-cfg
==> /usr/local/Cellar/[email protected]/3.8.6_1/bin/python3 -s setup.py --no-user-cfg
==> Caveats
Python has been installed as
  /usr/local/opt/[email protected]/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/[email protected]/libexec/bin

You can install Python packages with
  /usr/local/opt/[email protected]/bin/pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

==> Summary
๐Ÿบ  /usr/local/Cellar/[email protected]/3.8.6_1: 4,329 files, 69.4MB
โžœ  rembg-master git:(master) โœ— python --version
Python 2.7.16
โžœ  rembg-master git:(master) โœ— python3.8
zsh: command not found: python3.8
โžœ  rembg-master git:(master) โœ— pip3 install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/cb/28/91f26bd088ce8e22169032100d4260614fc3da435025ff389ef1d396a433/pip-20.2.4-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
  Rolling back uninstall of pip
  Moving to /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pip-19.2.3.dist-info/
   from /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/~ip-19.2.3.dist-info
  Moving to /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pip/
   from /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/~ip
  Moving to /Users/nikhilsingh/Library/Caches/com.apple.python/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pip/
   from /Users/nikhilsingh/Library/Caches/com.apple.python/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/~ip
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/3.8'
Consider using the `--user` option or check the permissions.

WARNING: You are using pip version 19.2.3, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
โžœ  rembg-master git:(master) โœ— pip3 install --upgrade pip --user
Collecting pip
  Using cached https://files.pythonhosted.org/packages/cb/28/91f26bd088ce8e22169032100d4260614fc3da435025ff389ef1d396a433/pip-20.2.4-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-20.2.4
WARNING: You are using pip version 19.2.3, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
โžœ  rembg-master git:(master) โœ— pip3 install --upgrade pip3 --user
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
ERROR: Could not find a version that satisfies the requirement pip3 (from versions: none)
ERROR: No matching distribution found for pip3
โžœ  rembg-master git:(master) โœ— pip3 install rembg

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Collecting rembg
  Using cached rembg-1.0.16.tar.gz (13 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting numpy==1.19.4
  Downloading numpy-1.19.4.zip (7.3 MB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 7.3 MB 2.6 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Users/nikhilsingh/Library/Python/3.8/lib/python/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp2c2qcd32
         cwd: /private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-wsstgq1n/numpy
    Complete output (225 lines):
    Processing numpy/random/_bounded_integers.pxd.in
    Processing numpy/random/_philox.pyx
    Processing numpy/random/_bounded_integers.pyx.in
    Processing numpy/random/_sfc64.pyx
    Processing numpy/random/_mt19937.pyx
    Processing numpy/random/bit_generator.pyx
    Processing numpy/random/mtrand.pyx
    Processing numpy/random/_generator.pyx
    Processing numpy/random/_pcg64.pyx
    Processing numpy/random/_common.pyx
    Cythonizing sources
    blas_opt_info:
    blas_mkl_info:
    customize UnixCCompiler
    C compiler: xcrun -sdk macosx clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64

    creating /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/var
    creating /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/var/folders
    creating /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/var/folders/bm
    creating /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn
    creating /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T
    creating /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k
    compile options: '-MMD -MF /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/file.c.d -c'
    xcrun: /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp96fh0k1k/file.c
      libraries mkl_rt not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    blis_info:
      libraries blis not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    openblas_info:
      libraries openblas not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    atlas_3_10_blas_info:
      libraries satlas not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    accelerate_info:
      libraries accelerate not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
    Library accelerate was not found. Ignoring
      libraries veclib not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
    Library veclib was not found. Ignoring
      FOUND:
        extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
        extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
        define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]

      FOUND:
        extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
        extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
        define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]

    non-existing path in 'numpy/distutils': 'site.cfg'
    lapack_opt_info:
    lapack_mkl_info:
      libraries mkl_rt not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    openblas_lapack_info:
      libraries openblas not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    openblas_clapack_info:
      libraries openblas,lapack not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    flame_info:
      libraries flame not found in ['/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib', '/usr/local/lib', '/usr/lib']
      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries tatlas,tatlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries tatlas,tatlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries tatlas,tatlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries lapack_atlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries satlas,satlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries satlas,satlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries satlas,satlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries ptf77blas,ptcblas,atlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries ptf77blas,ptcblas,atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries lapack_atlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries f77blas,cblas,atlas not found in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries f77blas,cblas,atlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/lib
      libraries f77blas,cblas,atlas not found in /usr/lib
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

      FOUND:
        extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
        extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
        define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]

    running dist_info
    running build_src
    build_src
    building py_modules sources
    creating build
    creating build/src.macosx-10.14.6-x86_64-3.8
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy/distutils
    building library "npymath" sources
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy/core
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npymath
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npymath/npy_math_internal.h
      adding 'build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npymath' to include_dirs.
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npymath/ieee754.c
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npymath/npy_math_complex.c
    None - nothing done with h_files = ['build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npymath/npy_math_internal.h']
    building library "npysort" sources
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common/npy_sort.h
      adding 'build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common' to include_dirs.
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort/quicksort.c
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort/mergesort.c
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort/timsort.c
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort/heapsort.c
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort/radixsort.c
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common/npy_partition.h
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort/selection.c
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common/npy_binsearch.h
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/npysort/binsearch.c
    None - nothing done with h_files = ['build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common/npy_sort.h', 'build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common/npy_partition.h', 'build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/common/npy_binsearch.h']
    building library "npyrandom" sources
    building extension "numpy.core._multiarray_tests" sources
    creating build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/multiarray
    conv_template:> build/src.macosx-10.14.6-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.c
    building extension "numpy.core._multiarray_umath" sources
    Running from numpy source directory.
    setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      run_build = parse_setuppy_commands()
    /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
      warnings.warn(msg)
    Traceback (most recent call last):
      File "/Users/nikhilsingh/Library/Python/3.8/lib/python/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
        main()
      File "/Users/nikhilsingh/Library/Python/3.8/lib/python/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/Users/nikhilsingh/Library/Python/3.8/lib/python/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/build_meta.py", line 156, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/build_meta.py", line 236, in run_setup
        super(_BuildMetaLegacyBackend,
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/build_meta.py", line 142, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 508, in <module>
        setup_package()
      File "setup.py", line 500, in setup_package
        setup(**metadata)
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-wsstgq1n/numpy/numpy/distutils/core.py", line 169, in setup
        return old_setup(**new_attr)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/dist_info.py", line 31, in run
        egg_info.run()
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-wsstgq1n/numpy/numpy/distutils/command/egg_info.py", line 24, in run
        self.run_command("build_src")
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-wsstgq1n/numpy/numpy/distutils/command/build_src.py", line 144, in run
        self.build_sources()
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-wsstgq1n/numpy/numpy/distutils/command/build_src.py", line 161, in build_sources
        self.build_extension_sources(ext)
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-wsstgq1n/numpy/numpy/distutils/command/build_src.py", line 318, in build_extension_sources
        sources = self.generate_sources(sources, ext)
      File "/private/var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/pip-install-wsstgq1n/numpy/numpy/distutils/command/build_src.py", line 378, in generate_sources
        source = func(extension, build_dir)
      File "numpy/core/setup.py", line 436, in generate_config_h
        moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
      File "numpy/core/setup.py", line 47, in check_types
        out = check_types(*a, **kw)
      File "numpy/core/setup.py", line 292, in check_types
        raise SystemError(
    SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Users/nikhilsingh/Library/Python/3.8/lib/python/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/bm/8v69908x5q11f27w9ydcn5kh0000gn/T/tmp2c2qcd32 Check the logs for full command output.```

Help appreciated, thanks!

Help needed with understanding the best use of alpha matting

Hi @danielgatis ,
From my previous comment on , i did some more research and experimentation and have found that the combinations of alpha matting fg, bg and erosion works well for a set of objects.
For example 240-10-3 with estimate_alpha_cf and estimate_foreground_ml works really really well for animals or things with fine edges like hairs.
190-100-3 with estimate_alpha_rw and estimate_foreground_cf works ok for humans and excellent for other non-living objects like phone, laptop, fruits, (things with more crisp boundaries).

Any thoughts or understanding on how to make the results for humans better?

I also have one other observation I found and thought to share.
For the same code and different machine specs, I am seeing different output. The main difference is of the CPU and RAM (both my machines don't have a GPU). In your opinion, does the capacity of the machine matters?

Uploading a few samples from my experiments. Any direction or help would be appreciated.

https://drive.google.com/file/d/1m0EokvSPmqjDp3hov5qm5jlcq6wkD8Rt/view?usp=sharing

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='docs.google.com', port=443)

Traceback (most recent call last):
File "/Users/apple/.pyenv/versions/3.8.6/bin/rembg", line 8, in
sys.exit(main())
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/rembg/cmd/cli.py", line 122, in main
remove(
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/rembg/bg.py", line 87, in remove
model = get_model(model_name)
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/rembg/bg.py", line 76, in get_model
return detect.load_model(model_name="u2net")
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/rembg/u2net/detect.py", line 83, in load_model
download_file_from_google_drive(
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/rembg/u2net/detect.py", line 28, in download_file_from_google_drive
response = session.get(URL, params={"id": id}, stream=True)
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/Users/apple/.pyenv/versions/3.8.6/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='docs.google.com', port=443): Max retries exceeded with url: /uc?export=download&id=1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x136a4b460>: Failed to establish a new connection: [Errno 60] Operation timed out'))

any way to increase speed ?

Hello,
first of all , thank you so much for sharing this cool tool, i love it.
i got one question , is there any way to increase its speed ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.