Spaces:
Running
Running
| 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"] | |