File size: 2,227 Bytes
841af59
 
1989a03
841af59
 
 
 
1989a03
841af59
1989a03
841af59
1989a03
841af59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b0ed745
 
 
841af59
b0ed745
 
 
 
841af59
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Use CUDA-enabled base image for GPU support
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV CUDA_HOME=/usr/local/cuda-11.8

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    python3.10 \
    python3-pip \
    git \
    wget \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    libgomp1 \
    libgl1-mesa-glx \
    && rm -rf /var/lib/apt/lists/*

# Create symbolic links for python
RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \
    ln -sf /usr/bin/pip3 /usr/bin/pip

# Upgrade pip
RUN pip install --upgrade pip setuptools wheel

# ===== CRITICAL: Install packages in EXACT ORDER to maintain compatibility =====

# Step 1: Install NumPy 1.26.4 FIRST (LOCKED)
RUN pip install --no-cache-dir numpy==1.26.4

# Step 2: Install compatible scientific packages
RUN pip install --no-cache-dir \
    scipy==1.11.4 \
    scikit-learn==1.3.2 \
    matplotlib==3.7.2

# Step 3: Install PyTorch with CUDA 11.8 support
RUN pip install --no-cache-dir \
    torch==2.1.0 \
    torchvision==0.16.0 \
    torchaudio==2.1.0 \
    --index-url https://download.pytorch.org/whl/cu118

# Step 4: Install AI/ML packages with LOCKED versions
RUN pip install --no-cache-dir \
    huggingface_hub==0.20.0 \
    safetensors==0.4.1 \
    diffusers==0.25.0 \
    transformers==4.36.0 \
    accelerate==0.28.0 \
    peft==0.8.2

# Step 5: Install computer vision and utility packages
RUN pip install --no-cache-dir \
    opencv-python-headless==4.8.1.78 \
    pillow

# Step 6: Install additional dependencies
RUN pip install --no-cache-dir \
    fvcore \
    iopath \
    av \
    omegaconf

# Step 7: Install Gradio COMPATIBLE with huggingface_hub==0.20.0
# Gradio 4.x requires newer huggingface_hub, so we use Gradio 3.x
RUN pip install --no-cache-dir gradio==3.50.2

# Step 8: Install additional web dependencies
RUN pip install --no-cache-dir \
    fastapi \
    uvicorn

# Copy application code
COPY . /app

# Create necessary directories
RUN mkdir -p /app/models /app/outputs

# Expose port for Hugging Face Spaces (default: 7860)
EXPOSE 7860

# Set the entrypoint
CMD ["python", "app.py"]