Image building happens once, running the container happens N times. Theres no reason to re-download the model every time it runs.
I also tried adding a volume for it at /model, mentioned in the Getting started page of the wiki, but it does not seem to pick up a pre-downloaded instance.
Hello,
There is indeed a problem in the wiki. /model doesn't correspond to the path where the models are actually extracted it seems. They are in /workspace/spleeter/pretrained_models, so you can mount a volume there, e.g.
nvidia-docker run -v $(pwd)/output:/output -v $(pwd)/pretrained_models:/workspace/spleeter/pretrained_models ...
Thanks! I see now that the MODEL_PATH environment variable can also control the location within the container, so I could make the example work without re-download by adding -e MODEL_PATH=/model to the command.
Indeed, you can also keep the command given in the wiki, and set the environment variable -e MODEL_PATH=/model when running the container.
We will probably also at some point distribute ready to use Docker image on DockerHub which will embed model directly.
In the interim, you can add this to your Dockerfile somewhere after the WORKDIR /workspace/spleeter command:
RUN mkdir -p ./pretrained_models/2stems && \
wget -nv https://github.com/deezer/spleeter/releases/download/v1.4.0/2stems.tar.gz && \
tar -xvzf 2stems.tar.gz -C ./pretrained_models/2stems && \
rm -f 2stems.tar.gz
This will download and extract the 2stems model to the right place (adjust for different models). Note that you'll need to rebuild after updating your Dockerfile.
I fixed the command in the wiki with the extra -e MODEL_PATH=/model option.
As suggested by @mickdekkers, you can also build your own image with the model you need (avoiding including all models when you only need one).
Most helpful comment
We will probably also at some point distribute ready to use Docker image on DockerHub which will embed model directly.