backgroundremover: RuntimeError: storage has wrong byte size

My sequence of commands on 4 different Ubuntu 22 boxes below. I’m about to try on a lower version of Ubuntu.

sudo apt install ffmpeg python3.10 or sudo apt install ffmpeg python3.10-dev

sudo apt install pip

pip install backgroundremover

backgroundremover -i "/path/to/image.jpeg" -o "output.png" or backgroundremover -i "/path/to/image.jpeg" -m "u2net" -o "output.png" or backgroundremover -i "/path/to/image.jpeg" -m "u2net_human_seg" -o "output.png" or backgroundremover -i "/path/to/image.jpeg" -m "u2netp" -o "output.png"

I got this error on all the boxes.

Traceback (most recent call last):
  File "/usr/local/bin/backgroundremover", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/backgroundremover/cmd/cli.py", line 239, in main
    remove(
  File "/usr/local/lib/python3.10/dist-packages/backgroundremover/bg.py", line 183, in remove
    model = get_model(model_name)
  File "/usr/local/lib/python3.10/dist-packages/backgroundremover/bg.py", line 171, in get_model
    return detect.load_model(model_name="u2net")
  File "/usr/local/lib/python3.10/dist-packages/backgroundremover/u2net/detect.py", line 82, in load_model
    torch.load(
  File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 815, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 1051, in _legacy_load
    typed_storage._untyped_storage._set_from_file(
**RuntimeError: storage has wrong byte size: expected %ld got %ld-2384061055873887482048**

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

Just for the record, I’m confirming that I tried this with the advice and it worked on a fresh box.

For some reason it still didn’t work on the old box.

If anyone else encounters this error, just do it in the order Johnathan specifies.

apt-get install python3.x apt-get install python3.x-dev apt-get install pip pip install backgroundremover