Spaces:
Running
Running
File size: 4,046 Bytes
d646931 cdee956 d646931 cdee956 9a7767a b2df948 dc5ece5 d068e4a b2df948 d646931 cdee956 42a9c43 cdee956 637d77d d646931 cdee956 d646931 8d3155f d646931 8d3155f cdee956 |
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
FROM python:3.10-slim
# System dependencies
RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Set Hugging Face cache for all model downloads (best practice for Spaces)
# ENV HF_HOME="/workspace/.cache/huggingface"
# RUN mkdir -p /workspace/.cache/huggingface
# ENV CACHE_DIR="/workspace/.cache"
# ENV HF_HOME="/workspace/.cache/huggingface"
# ENV TRANSFORMERS_CACHE="/workspace/.cache/huggingface"
# RUN mkdir -p /workspace/.cache/huggingface/hub && \
# chmod -R 777 /workspace/.cache
ENV CACHE_DIR="/data"
ENV HF_HOME="/data/huggingface"
ENV TRANSFORMERS_CACHE="/data/huggingface"
RUN mkdir -p /data/huggingface/models
RUN mkdir -p /data/huggingface/hub/models--h94--IP-Adapter
RUN mkdir -p /data/huggingface/.locks && chmod -R 777 /data
# Pre-download Stable Diffusion v1-5 weights into cache
RUN python -c "import torch; from diffusers import StableDiffusionImg2ImgPipeline; StableDiffusionImg2ImgPipeline.from_pretrained('runwayml/stable-diffusion-v1-5', cache_dir='/workspace/.cache/huggingface', torch_dtype=torch.float32)"
# Pre-download IP-Adapter weights (if using)
# RUN mkdir -p /workspace/.cache/huggingface/ip_adapter && \
# wget -O /workspace/.cache/huggingface/ip_adapter/ip-adapter_sd15.bin https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15.bin
# Copy app code
COPY . .
# Disable Gradio analytics (optional, but good for Spaces)
ENV GRADIO_ANALYTICS_ENABLED="False"
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
# EXPOSE 7860
# CMD ["python", "app.py"]
# FROM python:3.10-slim
# # System dependencies
# RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# WORKDIR /workspace
# # Install Python dependencies
# COPY requirements.txt .
# RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
# # Download models and adapters at build time
# # You can replace MODEL_ID or adapter repos as needed
# ENV CACHE_DIR="/data"
# ENV HF_HOME="/data"
# # ENV TRANSFORMERS_CACHE="/data"
# # ENV DEEPFACE_HOME="/data"
# # ENV INSIGHTFACE_HOME="/data/.insightface"
# RUN mkdir -p /data && \
# chmod -R 777 /data
# # -- Download Stable Diffusion v1-5 weights --
# # RUN python -c "from diffusers import StableDiffusionImg2ImgPipeline; StableDiffusionImg2ImgPipeline.from_pretrained('runwayml/stable-diffusion-v1-5', cache_dir='./models', torch_dtype='float32')"
# RUN python -c "import torch; from diffusers import StableDiffusionImg2ImgPipeline; StableDiffusionImg2ImgPipeline.from_pretrained('runwayml/stable-diffusion-v1-5', cache_dir='./models', torch_dtype=torch.float32)"
# RUN apt-get update && apt-get install -y wget
# # -- Download IP-Adapter weights (official Hugging Face repo) --
# RUN mkdir -p ./models/ip_adapter && \
# wget -O ./models/ip_adapter/ip-adapter_sd15.bin https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15.bin
# # Set Hugging Face cache for all model downloads (best practice for Spaces)
# ENV TRANSFORMERS_CACHE="/workspace/.cache/huggingface"
# RUN mkdir -p /workspace/.cache/huggingface && \
# chmod -R 777 /workspace
# # Pre-download Stable Diffusion v1-5 weights into cache
# RUN python -c "import torch; from diffusers import StableDiffusionImg2ImgPipeline; StableDiffusionImg2ImgPipeline.from_pretrained('runwayml/stable-diffusion-v1-5', cache_dir='/workspace/.cache/huggingface', torch_dtype=torch.float32)"
# # Pre-download IP-Adapter weights (if using)
# RUN mkdir -p /workspace/.cache/huggingface/ip_adapter && \
# wget -O /workspace/.cache/huggingface/ip_adapter/ip-adapter_sd15.bin https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15.bin
# # Copy app code
# COPY . .
# # Set environment (disable gradio analytics, useful for Spaces)
# ENV GRADIO_ANALYTICS_ENABLED="False"
# EXPOSE 7860
# CMD ["python", "app.py"]
|