File size: 1,267 Bytes
6bb73d5
 
 
 
 
 
 
 
 
 
 
 
 
4265309
0135310
4265309
6bb73d5
 
 
0135310
6bb73d5
 
 
 
 
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
FROM python:3.11-slim

RUN apt-get update && \
    apt-get install -y --no-install-recommends ffmpeg libsndfile1 git && \
    rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/.cache/huggingface
WORKDIR /home/user/app

RUN pip install --no-cache-dir --user torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu && \
    pip install --no-cache-dir --user librosa soundfile numpy fastapi "uvicorn[standard]" python-multipart huggingface_hub timm pandas matplotlib tqdm scikit-learn fvcore transformers && \
    pip install --no-cache-dir --user --no-deps git+https://github.com/awsaf49/sonics.git

# Bake model weights into the image so cold starts skip the download.
RUN python -c "from sonics import HFAudioClassifier; HFAudioClassifier.from_pretrained('awsaf49/sonics-spectttra-alpha-120s')"
RUN python -c "from transformers import AutoFeatureExtractor, AutoModelForAudioClassification; m='MattyB95/AST-ASVspoof5-Synthetic-Voice-Detection'; AutoFeatureExtractor.from_pretrained(m); AutoModelForAudioClassification.from_pretrained(m)"

COPY --chown=user app.py .

EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]