nadermx / backgroundremover

Background Remover lets you Remove Background from images and video using AI with a simple command line interface that is free and open source.
https://www.backgroundremoverai.com
MIT License
6.45k stars 535 forks source link

not able to run it on my laptop #75

Closed aoke79 closed 1 year ago

aoke79 commented 1 year ago

this is an amazing project, the effect is perfect, and i'd like to use it on my local laptop, but I failed. the command is very simple for me: python -m venv venv_back python.exe -m pip install --upgrade pip pip3 install torch torchvision torchaudio pip3 install ffmpeg backgroundremover when I tried to use it by "backgroundremover -i jan-02.jpg -o x.jpg", it shows below commands:

downloading model [u2net] to C:\Users\lin.u2net\u2net.pth ... downloading part 1 of u2net

Traceback (most recent call last): File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request response = conn.getresponse() File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connection.py", line 454, in getresponse httplib_response = super().getresponse() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 1375, in getresponse response.begin() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 318, in begin version, status, reason = self._read_status() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\lin\AIGC\venv_back\lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 844, in urlopen retries = retries.increment( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\util\retry.py", line 470, in increment raise reraise(type(error), error, _stacktrace) File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\util\util.py", line 38, in reraise raise value.with_traceback(tb) File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request response = conn.getresponse() File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connection.py", line 454, in getresponse httplib_response = super().getresponse() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 1375, in getresponse response.begin() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 318, in begin version, status, reason = self._read_status() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\lin\AIGC\venv_back\Scripts\backgroundremover.exe\main__.py", line 7, in File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\cmd\cli.py", line 239, in main remove( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 183, in remove model = get_model(model_name) File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 171, in get_model return detect.load_model(model_name="u2net") File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\u2net\detect.py", line 55, in load_model utilities.download_files_from_github( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\utilities.py", line 348, in download_files_from_github part_content = requests.get(url) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\sessions.py", line 701, in send r = adapter.send(request, kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\adapters.py", line 501, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

when I run it again, I've found below logs: Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\lin\AIGC\venv_back\Scripts\backgroundremover.exe\main__.py", line 7, in File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\cmd\cli.py", line 239, in main remove( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 183, in remove model = get_model(model_name) File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 171, in get_model return detect.load_model(model_name="u2net") File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\u2net\detect.py", line 82, in load_model torch.load( File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 815, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 1033, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) EOFError: Ran out of input

might you please help take a look at that? thanks very very much!

nadermx commented 1 year ago

Perhaps github was/is down? Try again? That seems like a requests error off quick look

El vie, 19 de may de 2023 01:54, aoke79 @.***> escribió:

this is an amazing project, the effect is perfect, and i'd like to use it on my local laptop, but I failed. the command is very simple for me: python -m venv venv_back python.exe -m pip install --upgrade pip pip3 install torch torchvision torchaudio pip3 install ffmpeg backgroundremover when I tried to use it by "backgroundremover -i jan-02.jpg -o x.jpg", it shows below commands:

downloading model [u2net] to C:\Users\lin.u2net\u2net.pth ... downloading part 1 of u2net

Traceback (most recent call last): File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request response = conn.getresponse() File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connection.py", line 454, in getresponse httplib_response = super().getresponse() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 1375, in getresponse response.begin() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 318, in begin version, status, reason = self._read_status() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\lin\AIGC\venv_back\lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 844, in urlopen retries = retries.increment( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\util\retry.py", line 470, in increment raise reraise(type(error), error, _stacktrace) File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\util\util.py", line 38, in reraise raise value.with_traceback(tb) File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request response = conn.getresponse() File "C:\lin\AIGC\venv_back\lib\site-packages\urllib3\connection.py", line 454, in getresponse httplib_response = super().getresponse() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 1375, in getresponse response.begin() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\http\client.py", line 318, in begin version, status, reason = self._read_status() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in

run_code exec(code, run_globals) File "C:\lin\AIGC\venv_back\Scripts\backgroundremover.exe_main.py", line 7, in File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\cmd\cli.py", line 239, in main remove( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 183, in remove model = get_model(model_name) File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 171, in get_model return detect.load_model(model_name="u2net") File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\u2net\detect.py", line 55, in load_model utilities.download_files_from_github( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\utilities.py", line 348, in download_files_from_github part_content = requests.get(url) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\sessions.py", line 701, in send r = adapter.send(request, kwargs) File "C:\lin\AIGC\venv_back\lib\site-packages\requests\adapters.py", line 501, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

when I run it again, I've found below logs: Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in

run_code exec(code, run_globals) File "C:\lin\AIGC\venv_back\Scripts\backgroundremover.exe_main.py", line 7, in File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\cmd\cli.py", line 239, in main remove( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 183, in remove model = get_model(model_name) File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 171, in get_model return detect.load_model(model_name="u2net") File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\u2net\detect.py", line 82, in load_model torch.load( File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 815, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 1033, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) EOFError: Ran out of input

might you please help take a look at that? thanks very very much!

— Reply to this email directly, view it on GitHub https://github.com/nadermx/backgroundremover/issues/75, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYACXDZGW7JLHC7KENKX6DXG4DKVANCNFSM6AAAAAAYHKUGIU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

aoke79 commented 1 year ago

thanks a lot for your quick response. I've found an interesting thing. as I've created a virtual enviroment, but the logs showed it still run the system python. might you please know why? Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\lin\AIGC\venv_back\Scripts\backgroundremover.exe\main__.py", line 7, in File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\cmd\cli.py", line 239, in main remove( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 183, in remove model = get_model(model_name) File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 171, in get_model return detect.load_model(model_name="u2net") File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\u2net\detect.py", line 82, in load_model torch.load( File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 815, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 1033, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) EOFError: Ran out of input

nadermx commented 1 year ago

What command are you running?

El vie, 19 de may de 2023 02:44, aoke79 @.***> escribió:

thanks a lot for your quick response. I've found an interesting thing. as I've created a virtual enviroment, but the logs showed it still run the system python. might you please know why? Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in

run_code exec(code, run_globals) File "C:\lin\AIGC\venv_back\Scripts\backgroundremover.exe_main.py", line 7, in File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\cmd\cli.py", line 239, in main remove( File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 183, in remove model = get_model(model_name) File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\bg.py", line 171, in get_model return detect.load_model(model_name="u2net") File "C:\lin\AIGC\venv_back\lib\site-packages\backgroundremover\u2net\detect.py", line 82, in load_model torch.load( File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 815, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "C:\lin\AIGC\venv_back\lib\site-packages\torch\serialization.py", line 1033, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) EOFError: Ran out of input

— Reply to this email directly, view it on GitHub https://github.com/nadermx/backgroundremover/issues/75#issuecomment-1554085144, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYACXBFW2VLKV7LNRT6MSTXG4JDFANCNFSM6AAAAAAYHKUGIU . You are receiving this because you commented.Message ID: @.***>

aoke79 commented 1 year ago

backgroundremover -i jan-02.jpg -o x.jpg or Script\backgroundremover.exe -i jan-02.jpg -o x.jpg

nadermx commented 1 year ago

try this (please note the quotes, and the output extension) backgroundremover -i "/path/to/image.jpeg" -o "output.png"

aoke79 commented 1 year ago

the same error: I've run it through CPU, not on GPU.

(venv_back) C:\ed\GPT\backgroundremover>backgroundremover -i "YangGongru.png" -o "YangGongru-output-0.png" YangGongru-output-0.png Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\ed\GPT\venv_back\Scripts\backgroundremover.exe\main__.py", line 7, in File "C:\ed\GPT\venv_back\lib\site-packages\backgroundremover\cmd\cli.py", line 239, in main remove( File "C:\ed\GPT\venv_back\lib\site-packages\backgroundremover\bg.py", line 183, in remove model = get_model(model_name) File "C:\ed\GPT\venv_back\lib\site-packages\backgroundremover\bg.py", line 171, in get_model return detect.load_model(model_name="u2net") File "C:\ed\GPT\venv_back\lib\site-packages\backgroundremover\u2net\detect.py", line 82, in load_model torch.load( File "C:\ed\GPT\venv_back\lib\site-packages\torch\serialization.py", line 815, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "C:\ed\GPT\venv_back\lib\site-packages\torch\serialization.py", line 1033, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) EOFError: Ran out of input

aoke79 commented 1 year ago

maybe, it lacked the u2net pth file, do you please know where is the default folder, the detect loaded the pth file? thanks a lot

aoke79 commented 1 year ago

maybe, it lacked the u2net pth file, do you please know where is the default folder, the detect loaded the pth file? thanks a lot

Yes, I've confirmed it. Might you please help upload u2.net.pth and u2net_human_seg.pth to server. the github is very not friendly for Chinese users. :(, or please give the link, and I can download it by myself. thanks a lot,

aoke79 commented 1 year ago

I've fixed it, thanks very much

davidkern13 commented 11 months ago

I have same issue how did you fix it ?

nadermx commented 11 months ago

Just upgrade your version, should work now pip install --upgrade backgroundremover

El vie, 4 de ago de 2023 13:22, David Kern @.***> escribió:

I have same issue how did you fix it ?

— Reply to this email directly, view it on GitHub https://github.com/nadermx/backgroundremover/issues/75#issuecomment-1666070867, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYACXGVZ6FSSEH3OFQVHV3XTVDYJANCNFSM6AAAAAAYHKUGIU . You are receiving this because you commented.Message ID: @.***>