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

Docker always download models #105

Open
DavidGasku opened this issue Nov 6, 2023 · 9 comments
Open

Docker always download models #105

DavidGasku opened this issue Nov 6, 2023 · 9 comments

Comments

@DavidGasku
Copy link

I'm following the exact commands, but every call to the container is downloading the models. Not sure why.

@nadermx
Copy link
Owner

nadermx commented Nov 12, 2023

I still have to read up on docker. The file was made by some one, if you want to check it and see perhaps there is something in the docker setup where it doesn't check the /u2net directory?

@DavidGasku
Copy link
Author

Thanks, I'll try to check it, maybe I can fix it. I'll let you know.

@HotNoob
Copy link

HotNoob commented Jan 16, 2024

bump

@Stehos
Copy link

Stehos commented Jan 17, 2024

the issue still persist:

backgroundremover -i "./AB6-CF-8-303.jpg" -o "AB6-CF-8-303.png"
AB6-CF-8-303.png
downloading model [u2net] to /root/.u2net/u2net.pth ...
downloading part 1 of u2net
finished downloading part 1 of u2net
downloading part 2 of u2net
finished downloading part 2 of u2net
downloading part 3 of u2net
finished downloading part 3 of u2net
downloading part 4 of u2net
finished downloading part 4 of u2net

@nadermx
Copy link
Owner

nadermx commented Jan 17, 2024 via email

@nadermx
Copy link
Owner

nadermx commented Jan 17, 2024 via email

@Stehos
Copy link

Stehos commented Jan 17, 2024

@nadermx yes, this is via docker use on ubuntu 20.04.6. btw on macbook i was not able to start docker instance. It was stopped at:

=> [builder 3/7] RUN conda install 'ffmpeg>=4.4.0' -c conda-forge                                                                                                                           22.3s
 => ERROR [builder 4/7] RUN conda install pytorch torchvision torchaudio cpuonly -c pytorch                                                                                                   6.3s
------
 > [builder 4/7] RUN conda install pytorch torchvision torchaudio cpuonly -c pytorch:
0.320 Could not load conda plugin `conda-libmamba-solver`:
0.320
0.320 libarchive.so.19: cannot open shared object file: No such file or directory
0.488 Collecting package metadata (current_repodata.json): ...working... done
2.158 Solving environment: ...working... unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
2.159 Collecting package metadata (repodata.json): ...working... done
5.891 Solving environment: ...working... unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
5.892
5.892 PackagesNotFoundError: The following packages are not available from current channels:
5.892
5.892   - torchaudio
5.892
5.892 Current channels:
5.892
5.892   - https://conda.anaconda.org/pytorch/linux-aarch64
5.892   - https://conda.anaconda.org/pytorch/noarch
5.892   - https://repo.anaconda.com/pkgs/main/linux-aarch64
5.892   - https://repo.anaconda.com/pkgs/main/noarch
5.892   - https://repo.anaconda.com/pkgs/r/linux-aarch64
5.892   - https://repo.anaconda.com/pkgs/r/noarch
5.892
5.892 To search for alternate channels that may provide the conda package you're
5.892 looking for, navigate to
5.892
5.892     https://anaconda.org
5.892
5.892 and use the search bar at the top of the page.
5.892
5.892
------
Dockerfile:11
--------------------
   9 |
  10 |     RUN conda install 'ffmpeg>=4.4.0' -c conda-forge
  11 | >>> RUN conda install pytorch torchvision torchaudio cpuonly -c pytorch
  12 |
  13 |     WORKDIR /usr/local/src

@ErikXu
Copy link

ErikXu commented Feb 20, 2024

You could try to mount the models to host machine. Then the models will be downloaded only once.

like:
alias backgroundremover='docker run -it --rm -v "$(pwd):/tmp" -v /root/model:/root bgremover:latest'

@charles-large
Copy link

building on the previous comment, I was able to download and mount the model to prevent the container from downloading it every time.

Looking at the code, an environmental variable is first checked for the existance of a path to the model

I was already mounting a local volume into the container and just moved the model to my current directory before mounting. Downloaded model from here

My full command where I reference the path to my downloaded model in environmental variable. "U2NETP_PATH" would need to be changed to the model you are using. Reference code above.

docker run -it --rm -e U2NETP_PATH=/tmp/u2netp.pth -v ".:/tmp" bgremover:latest -i <inputFile> -o <outputFile> -m "u2netp"

It didn't save me a lot of time in processing speed, as the model sizes are pretty small to download and I have a decent internet speed, but the output no longer shows messages of having to download the model every time.

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

6 participants