File size: 1,565 Bytes
29c3be9
607c4f0
 
29c3be9
 
 
607c4f0
 
 
 
29c3be9
607c4f0
 
 
 
 
 
 
 
 
 
29c3be9
 
607c4f0
29c3be9
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1 ffmpeg git curl ca-certificates \
    && rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH \
    ABSOLUTION_DATA_DIR=/data ABSOLUTION_FALLBACK_DIR=/tmp/omega_data \
    ABSOLUTION_MAX_UPLOAD_MIB=200 \
    ABSOLUTION_DEMUCS_REPO=/home/user/demucs_models ABSOLUTION_DEMUCS_MAX_SECONDS=120 \
    OMP_NUM_THREADS=2 TORCH_HOME=/home/user/.cache/torch
WORKDIR /home/user/app
# CPU-only PyTorch + Demucs (demucs.api lives on the upstream main branch, not in PyPI 4.0.1)
RUN pip install --no-cache-dir --user --index-url https://download.pytorch.org/whl/cpu \
        torch==2.1.2 torchaudio==2.1.2 \
    && pip install --no-cache-dir --user "numpy<2" \
        "demucs @ git+https://github.com/adefossez/demucs@2883f3db65617d6d178c6ed10d869dc14e44e59b"
# Official htdemucs v4 checkpoint, verified by SHA-256 at build time
RUN mkdir -p $ABSOLUTION_DEMUCS_REPO && cd $ABSOLUTION_DEMUCS_REPO \
    && curl -fsSL -o 955717e8-8726e21a.th https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/955717e8-8726e21a.th \
    && echo "8726e21a993978c7ba086d3872e7608d7d5bfca646ca4aca459ffda844faa8b4  955717e8-8726e21a.th" | sha256sum -c - \
    && printf "models: ['955717e8']\n" > htdemucs.yaml
COPY --chown=user pyproject.toml requirements.txt ./
COPY --chown=user app ./app
RUN pip install --no-cache-dir --user . "numpy<2"
EXPOSE 7860
CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "7860"]