File size: 1,697 Bytes
ca4beaa
 
 
 
 
 
737fe58
ca4beaa
479a2b5
ca4beaa
 
 
 
 
 
 
 
 
3e25ef4
ca4beaa
 
efff8de
 
 
 
 
 
 
 
ca4beaa
 
479a2b5
ca4beaa
 
 
838d140
52e8406
479a2b5
ca4beaa
 
 
 
 
 
 
 
efff8de
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
FROM python:3.11-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    redis-server \
    git \
    libgl1 \
    libglib2.0-0 \
    libgomp1 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Step 1: Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir -r requirements.txt

# Step 2: Runtime defaults for Hugging Face Spaces
ENV HF_HUB_ENABLE_HF_TRANSFER=1 \
    DEBUG=false \
    RESET_JOBS_ON_STARTUP=true \
    JOB_TTL_SECONDS=3600 \
    JOB_CLEANUP_INTERVAL_SECONDS=300 \
    CELERY_BROKER_URL=redis://localhost:6379/0 \
    CELERY_RESULT_BACKEND=redis://localhost:6379/1

# Step 3. Download models for caching
RUN mkdir -p ./models
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('zeyadcode/ov_owlv2_model', local_dir='./models/ov_owlv2_model')"    
RUN python -c "from ultralytics import SAM; import os; os.chdir('./models'); SAM('mobile_sam.pt')"
RUN python -c "from transformers import AutoProcessor; AutoProcessor.from_pretrained('google/owlv2-base-patch16-ensemble')"
RUN python -c "import torch; original_load = torch.jit.load; torch.jit.load = lambda *a, **kw: original_load(*a, **{**kw, 'map_location': 'cpu'}); from simple_lama_inpainting import SimpleLama; SimpleLama()"
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('zeyadcode/ov_sdxl_turbo_inpaint', local_dir='./models/ov_sdxl_turbo_inpaint')"


# Step 4: Copy the rest of the application
COPY . .

RUN chmod +x start.sh

EXPOSE 7860

CMD ["./start.sh"]