Spaces:
Sleeping
Sleeping
Factor Studios commited on
Create Dockerfile
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667FROM python:3.11-slim-bullseye
# Install system dependencies with clean up in single RUN layer# RUN sed -i 's/main/main contrib non-free/' /etc/apt/sources.list && \# apt-get update && \# apt-get install -y --no-install-recommends \# unrar \# libgl1 \# libglib2.0-0 \# # ffmpeg for video processing# ffmpeg \# # git for transformers dependencies# git \# && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Upgrade pip and install core dependencies firstRUN pip install --no-cache-dir --upgrade pip setuptools wheel packaging
# Install optimized CPU-only PyTorch stack
# Copy requirements and install with special handlingCOPY requirements.txt .RUN pip install --no-cache-dir \ -r requirements.txt \ --find-links https://download.pytorch.org/whl/cpu \ --extra-index-url https://pypi.org/simple
# # Install transformers with specific version that works with BLIP-2# RUN pip install --no-cache-dir \# accelerate==0.27.2 \# transformers==4.36.2 \# timm==0.9.12 \# einops==0.7.0 \# bitsandbytes==0.42.0 # Helps with memory optimization
# For BLIP-2 specifically, we need theseRUN pip install --no-cache-dir \ protobuf==3.20.3 \ sentencepiece==0.2.0
# Copy application code with proper permissionsCOPY --chown=1000:1000 . .
# Create non-root user and set permissionsRUN useradd -m -u 1000 user && \ chown -R user:user /app && \ mkdir -p /app/downloads /app/extracted /app/extracted_frames /app/analysis_results && \ chown -R user:user /app/*
USER user
# Environment variables for better performance and less loggingENV HF_HUB_DISABLE_PROGRESS=1ENV TF_CPP_MIN_LOG_LEVEL=3ENV PYTORCH_NO_CUDA_MEMORY_CACHING=1ENV TOKENIZERS_PARALLELISM=falseENV PYTHONUNBUFFERED=1
# Set this if you're only using CPUENV CUDA_VISIBLE_DEVICES=""
# Pre-download the BLIP-2 model during build (optional)# RUN python -c "from transformers import AutoModel; AutoModel.from_pretrained('Salesforce/blip2-opt-2.7b', trust_remote_code=True)"
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]DockerfileAdded+67