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
Download image/fsd/Dockerfile from deepsafe/deepsafe-services: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/deepsafe/deepsafe-services/resolve/main/image/fsd/Dockerfile
- Command line
-
hf download hf://deepsafe/deepsafe-services/image/fsd/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/deepsafe/deepsafe-services/resolve/main/image/fsd/Dockerfile
1.81 kB
| FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV PYTHONUNBUFFERED=1 | |
| WORKDIR /app | |
| # System deps (using Python 3.10 from Ubuntu -- bypassing model_code's >=3.12 constraint) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 python3-pip python3-dev \ | |
| git wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN ln -sf /usr/bin/python3 /usr/bin/python | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel | |
| # Clone the FSD repo | |
| RUN git clone https://github.com/ductai199x/Forensic-Self-Descriptions-CVPR25.git model_code | |
| # Install PyTorch with CUDA 12.1 (replaces CPU-only install) | |
| RUN pip install --no-cache-dir \ | |
| torch==2.5.1 \ | |
| --index-url https://download.pytorch.org/whl/cu121 | |
| # Install FSD inference dependencies manually | |
| RUN pip install --no-cache-dir \ | |
| "scipy>=1.10.0" \ | |
| "pillow>=10.0.0" \ | |
| pillow-heif \ | |
| click \ | |
| tqdm \ | |
| "scikit-learn>=1.6.0" | |
| # Install FSD package: bypass both deps AND python-requires check | |
| # The model_code requires Python >=3.12 but works fine on 3.10 | |
| RUN pip install --no-deps --no-build-isolation -e ./model_code 2>/dev/null || \ | |
| (cd model_code && pip install --no-deps -e . --config-settings="--build-option=--skip-requires-python") 2>/dev/null || \ | |
| (cd model_code && python3 setup.py develop --no-deps 2>/dev/null) || \ | |
| echo "FSD model_code install skipped -- will use direct imports" | |
| # Install service-layer deps | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY app.py . | |
| RUN mkdir -p /app/weights | |
| COPY weights/ /app/weights/ | |
| ENV MODEL_PORT=5005 | |
| ENV PRELOAD_MODEL=false | |
| ENV MODEL_TIMEOUT=600 | |
| ENV WEIGHTS_DIR=/app/weights | |
| EXPOSE 5005 | |
| RUN adduser --disabled-password --gecos '' appuser | |
| USER appuser | |
| CMD ["python", "app.py"] | |