Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u2net file download failed #39

Closed
loop965 opened this issue Nov 17, 2020 · 7 comments
Closed

u2net file download failed #39

loop965 opened this issue Nov 17, 2020 · 7 comments

Comments

@loop965
Copy link

loop965 commented Nov 17, 2020

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'))

@loop965
Copy link
Author

loop965 commented Nov 17, 2020

I know , the file name should be modified u2net.pth ---> u2net,u2netp.pth ---> u2netp,it will work

@loop965 loop965 closed this as completed Nov 17, 2020
@tltucker
Copy link

I cannot get rembg to work.. Running Manjaro, python 3.10 and get the following:

rembg -p test test2
Downloading u2net.pth to /home/ttucker/.u2net: 2.16kiB [00:00, 5.94MiB/s] | 0/4 [00:00<?, ?it/s]
0%| | 0/4 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/ttucker/.local/bin/rembg", line 8, in
sys.exit(main())
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/cmd/cli.py", line 132, in main
remove(
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/bg.py", line 90, in remove
model = get_model(model_name)
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/bg.py", line 78, in get_model
return detect.load_model(model_name="u2net")
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/u2net/detect.py", line 109, in load_model
net.load_state_dict(torch.load(path))
File "/home/ttucker/.local/lib/python3.10/site-packages/torch/serialization.py", line 713, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/ttucker/.local/lib/python3.10/site-packages/torch/serialization.py", line 920, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

@danielgatis
Copy link
Owner

try download these files by yourself:
https://github.com/danielgatis/rembg#models

@tltucker
Copy link

Tried that. Downloaded them to /home//.u2net
I even made multiple copies with different extensions in case that helped
Contents of .u2net
-rw-r--r-- 1 ttucker ttucker 175997641 May 12 12:05 u2net
-rw-r--r-- 1 ttucker ttucker 176194565 May 12 12:00 u2net_cloth_seg
-rw-r--r-- 1 ttucker ttucker 176194565 May 12 12:00 u2net_cloth_seg.onnx
-rw-r--r-- 1 ttucker ttucker 176194565 May 12 12:00 u2net_cloth_seg.pth
-rw-r--r-- 1 ttucker ttucker 175997641 May 12 08:46 u2net_human_seg
-rw-r--r-- 1 ttucker ttucker 175997641 May 12 12:00 u2net_human_seg.onnx
-rw-r--r-- 1 ttucker ttucker 175997641 May 12 08:46 u2net_human_seg.pth
-rw-r--r-- 1 ttucker ttucker 175997641 May 12 12:05 u2net.onnx
-rw-r--r-- 1 ttucker ttucker 4574861 May 12 11:59 u2netp
-rw-r--r-- 1 ttucker ttucker 4574861 May 12 11:59 u2netp.onnx
-rw-r--r-- 1 ttucker ttucker 4574861 May 12 11:59 u2netp.pth
-rw-r--r-- 1 ttucker ttucker 175997641 May 12 12:05 u2net.pth

Gave the same error, but I noticed that it TRIED to download u2net.pth and overwrote the file that I downloaded.
-rw-r--r-- 1 ttucker ttucker 2213 May 12 12:07 u2net.pth

It is quite a bit smaller than the one I downloaded.

rembg -p test test2
Downloading u2net.pth to /home/ttucker/.u2net: 2.16kiB [00:00, 6.24MiB/s] | 0/4 [00:00<?, ?it/s]
0%| | 0/4 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/ttucker/.local/bin/rembg", line 8, in
sys.exit(main())
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/cmd/cli.py", line 132, in main
remove(
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/bg.py", line 90, in remove
model = get_model(model_name)
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/bg.py", line 78, in get_model
return detect.load_model(model_name="u2net")
File "/home/ttucker/.local/lib/python3.10/site-packages/rembg/u2net/detect.py", line 109, in load_model
net.load_state_dict(torch.load(path))
File "/home/ttucker/.local/lib/python3.10/site-packages/torch/serialization.py", line 713, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/ttucker/.local/lib/python3.10/site-packages/torch/serialization.py", line 920, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

@tltucker
Copy link

Don't know what the difference is, but I tried it on Linux Mint 20.3 and it worked as is.. It gave the above errors in Manjaro..

@danielgatis
Copy link
Owner

try to update the rembg and keep only the onnx version

@tltucker
Copy link

I did notice when I was running pip on manjaro vs linux mint.
Manjaro shows the following:

pip --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see pypa/pip#5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 21.0 from /usr/lib/python3.10/site-packages/pip (python 3.10)

~/.local/bin/rembg --version
usage: rembg [-h] [-m {u2net,u2net_human_seg,u2net,u2netp,u2net_cloth_seg}] [-a [ALPHA_MATTING]] [-af ALPHA_MATTING_FOREGROUND_THRESHOLD]
[-ab ALPHA_MATTING_BACKGROUND_THRESHOLD] [-ae ALPHA_MATTING_ERODE_SIZE] [-az ALPHA_MATTING_BASE_SIZE] [-p PATH PATH] [-o [OUTPUT]]
[input]

And yet, when I run the same on Linux Mint:

pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

~/.local/bin/rembg --version
rembg, version 2.0.13

They are different versions, and use different commands to work, so I am not sure what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants