tejani commited on
Commit
e34f8f1
·
verified ·
1 Parent(s): 4e9006d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -31
Dockerfile CHANGED
@@ -1,50 +1,40 @@
 
1
  FROM python:3.10-slim
2
 
3
  # Set working directory
4
  WORKDIR /app
5
 
6
- # Install system dependencies, including libgl1 for OpenCV
7
  RUN apt-get update && apt-get install -y \
8
  git \
9
- git-lfs \
10
- gcc \
11
- python3-dev \
12
  libgl1 \
13
  libglib2.0-0 \
 
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Initialize git-lfs
17
- RUN git lfs install
18
-
19
- # Clone the fastsdcpu repository
20
  RUN git clone https://github.com/rupeshs/fastsdcpu.git .
21
 
22
- # Create writable directories for cache, configs, and results
23
- RUN mkdir -p /app/.cache/huggingface /app/configs /app/results && \
24
- chmod -R 777 /app/.cache /app/configs /app/results
25
 
26
- # Set environment variables for Hugging Face cache and OpenVINO telemetry
27
- ENV HF_HOME=/app/.cache/huggingface
28
- ENV XDG_CACHE_HOME=/app/.cache
29
- ENV OPENVINO_TELEMETRY=0
30
 
31
- # Install Python dependencies
32
- RUN python -m venv env && \
33
- . env/bin/activate && \
34
- pip install --upgrade pip && \
35
- pip install torch==2.2.2 --index-url https://download.pytorch.org/whl/cpu && \
36
- pip install -r requirements.txt
37
 
38
- # Download a default model (corrected URL for lcm-lora-sdv1-5)
39
- RUN git clone https://huggingface.co/latent-consistency/lcm-lora-sdv1-5 /models/lcm-lora-sdv1-5 || \
40
- echo "Model clone failed. Please check network or manually download the model."
41
 
42
- # Configure the model path
43
- RUN echo "/models/lcm-lora-sdv1-5" > configs/lcm-lora-models.txt && \
44
- chmod 666 configs/lcm-lora-models.txt
45
 
46
- # Expose the API port
47
- EXPOSE 7860
 
48
 
49
- # Activate virtual environment and run the API server
50
- CMD ["/bin/bash", "-c", ". env/bin/activate && python src/app.py --api"]
 
1
+ # Use Python 3.10 slim as the base image for compatibility with FastSD CPU
2
  FROM python:3.10-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies required for FastSD CPU
8
  RUN apt-get update && apt-get install -y \
9
  git \
 
 
 
10
  libgl1 \
11
  libglib2.0-0 \
12
+ wget \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Clone the FastSD CPU repository
 
 
 
16
  RUN git clone https://github.com/rupeshs/fastsdcpu.git .
17
 
18
+ # Create a virtual environment and activate it
19
+ RUN python -m venv /app/env
20
+ ENV PATH="/app/env/bin:$PATH"
21
 
22
+ # Upgrade pip and install Python dependencies
23
+ RUN pip install --no-cache-dir --upgrade pip
24
+ RUN pip install --no-cache-dir -r requirements.txt
 
25
 
26
+ # Install OpenVINO for performance optimization (optional)
27
+ RUN pip install --no-cache-dir openvino-dev
 
 
 
 
28
 
29
+ # Pre-download the default model (stabilityai/sd-turbo) to avoid runtime downloads
30
+ RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='stabilityai/sd-turbo', local_dir='/app/models/sd-turbo')"
 
31
 
32
+ # Expose port 8000 for the API server
33
+ EXPOSE 8000
 
34
 
35
+ # Set environment variables for Hugging Face Spaces
36
+ ENV PYTHONUNBUFFERED=1
37
+ ENV DEVICE=cpu
38
 
39
+ # Command to run the API server
40
+ CMD ["python", "src/app.py", "--api"]