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/universal/Dockerfile from deepsafe/deepsafe-services: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/deepsafe/deepsafe-services/resolve/main/image/universal/Dockerfile
- Command line
-
hf download hf://deepsafe/deepsafe-services/image/universal/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/deepsafe/deepsafe-services/resolve/main/image/universal/Dockerfile
1.69 kB
| FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV PYTHONUNBUFFERED=1 | |
| WORKDIR /app | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 python3-pip git wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN ln -sf /usr/bin/python3 /usr/bin/python | |
| # Install PyTorch with CUDA 12.1 (upgraded from 1.11/CUDA 11.3 for Blackwell support) | |
| RUN pip install --no-cache-dir \ | |
| torch==2.5.1 torchvision==0.20.1 \ | |
| --index-url https://download.pytorch.org/whl/cu121 | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY app.py . | |
| # Clone the repository | |
| RUN git clone https://github.com/WisconsinAIVision/UniversalFakeDetect.git universalfakedetect && \ | |
| mkdir -p universalfakedetect/pretrained_weights | |
| RUN python -c "import torch; import os; os.makedirs('/root/.cache/clip', exist_ok=True)" && \ | |
| wget -O /root/.cache/clip/ViT-L-14.pt https://openaipublic.azureedge.net/clip/models/b8cca3fd41ae0c99ba7e8951adf17d267cdb84cd88be6f7c2e0eca1737a03836/ViT-L-14.pt | |
| # Download the weights file separately to avoid timeouts during startup | |
| RUN wget -O universalfakedetect/pretrained_weights/fc_weights.pth \ | |
| https://github.com/WisconsinAIVision/UniversalFakeDetect/raw/main/pretrained_weights/fc_weights.pth | |
| # Set environment variables | |
| ENV MODEL_PORT=5003 | |
| ENV USE_GPU=false | |
| ENV TIMEOUT=600 | |
| # Expose port | |
| EXPOSE 5003 | |
| # Drop root privileges | |
| RUN adduser --disabled-password --gecos '' appuser | |
| USER appuser | |
| # Run the application with gunicorn for better timeout handling | |
| CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "5003", "--timeout-keep-alive", "600"] |