File size: 1,300 Bytes
10c2c93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use an official Ubuntu base image (no CUDA by default)
FROM ubuntu:20.04

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    python3.10 \
    python3-pip \
    python3-dev \
    git \
    && rm -rf /var/lib/apt/lists/*

# Set Python 3.10 as default python
RUN ln -s /usr/bin/python3.10 /usr/bin/python

# Install Python packages (CPU-compatible PyTorch by default)
RUN pip3 install --no-cache-dir \
    diffusers==0.2.4 \
    torch==1.12.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu \
    ftfy==6.1.1 \
    scipy==1.9.0 \
    transformers==4.21.1 \
    pillow \
    numpy \
    tqdm

# Copy all necessary files
COPY image_to_image.py .
COPY predict.py .
COPY script/download-weights .

# Create directories for cache and outputs
RUN mkdir -p /app/diffusers-cache /tmp

# Set environment variables
ENV PYTHONPATH=/app
ENV MODEL_CACHE=/app/diffusers-cache

# Make the weights download script executable
RUN chmod +x /app/download-weights

# Default command - can be overridden when running the container
CMD ["python", "predict.py"]

# Note: You'll need to run the weights download script separately with your Hugging Face token
# Example: docker run -it <image_name> /app/download-weights <your-hugging-face-auth-token>