Instructions to use deepsafe/deepsafe-services with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use deepsafe/deepsafe-services with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("deepsafe/deepsafe-services", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
File size: 1,556 Bytes
4b0b144 | 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
git ffmpeg libsndfile1 wget \
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN ln -sf /usr/bin/python3 /usr/bin/python
WORKDIR /app
# Install PyTorch with CUDA 12.1
RUN pip install --no-cache-dir \
torch==2.5.1 torchaudio==2.5.1 \
--index-url https://download.pytorch.org/whl/cu121
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Clone SafeEar repository (for model code imports)
RUN git clone --depth 1 https://github.com/LetterLiGo/SafeEar.git /app/safeear_repo
# Install the fairseq fork with C extensions PATCHED OUT
# (same proven patch used by ShiftySpeech and Nes2Net --
# C extensions are not needed for checkpoint loading)
WORKDIR /app/safeear_repo/fairseq_ours
RUN sed -i 's/ext_modules=extensions/ext_modules=[]/' setup.py && \
pip install --no-cache-dir --no-deps -e .
WORKDIR /app
# Download model weights from HuggingFace
RUN mkdir -p /app/weights && \
wget -q -O /app/weights/SpeechTokenizer.pt \
"https://huggingface.co/TEC2004/SafeEar-ASV19-spoof-detection/resolve/main/SpeechTokenizer.pt" && \
wget -q -O /app/weights/model.ckpt \
"https://huggingface.co/TEC2004/SafeEar-ASV19-spoof-detection/resolve/main/model.ckpt"
COPY api.py .
EXPOSE 8002
RUN adduser --disabled-password --gecos '' appuser
USER appuser
CMD ["python", "api.py"]
|