File size: 1,693 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
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"]