File size: 1,209 Bytes
e34f8f1 5c0f98c e34f8f1 5c0f98c 0864015 e34f8f1 5c0f98c e34f8f1 5c0f98c e34f8f1 0864015 e34f8f1 0864015 e34f8f1 5c0f98c e34f8f1 5c0f98c e34f8f1 5c0f98c e34f8f1 5c0f98c e34f8f1 | 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 | # Use Python 3.10 slim as the base image for compatibility with FastSD CPU
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install system dependencies required for FastSD CPU
RUN apt-get update && apt-get install -y \
git \
libgl1 \
libglib2.0-0 \
wget \
&& rm -rf /var/lib/apt/lists/*
# Clone the FastSD CPU repository
RUN git clone https://github.com/rupeshs/fastsdcpu.git .
# Create a virtual environment and activate it
RUN python -m venv /app/env
ENV PATH="/app/env/bin:$PATH"
# Upgrade pip and install Python dependencies
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Install OpenVINO for performance optimization (optional)
RUN pip install --no-cache-dir openvino-dev
# Pre-download the default model (stabilityai/sd-turbo) to avoid runtime downloads
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='stabilityai/sd-turbo', local_dir='/app/models/sd-turbo')"
# Expose port 8000 for the API server
EXPOSE 8000
# Set environment variables for Hugging Face Spaces
ENV PYTHONUNBUFFERED=1
ENV DEVICE=cpu
# Command to run the API server
CMD ["python", "src/app.py", "--api"] |