vfx-2 / Dockerfile
TaqiRaza512's picture
updating Docker for spaces
5b1d5ea
FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-runtime
SHELL ["/bin/bash", "-c"]
# ---------------- Environment Variables ----------------
ENV DEBIAN_FRONTEND=noninteractive
ENV HOME=/root
ENV HF_HOME=/app/hf_cache
ENV TRANSFORMERS_CACHE=/app/hf_cache
ENV PYTHONUNBUFFERED=1
ENV PATH="/usr/local/bin:$PATH"
ENV ROLL_MODELS_DIR="/data/human-segmentation/Models"
ENV PYTHONPATH="/app:${PYTHONPATH}"
# ---------------- System Dependencies ----------------
RUN apt-get update && apt-get install -y \
git git-lfs bash curl wget procps unzip tar bzip2 \
libgl1-mesa-glx libglib2.0-0 \
build-essential gcc g++ python3-dev \
libgl1-mesa-dev libegl1 libxrandr-dev libx11-dev libxext-dev libxi-dev \
htop vim nano && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# ---------------- Workdir & Code ----------------
WORKDIR /app
COPY ffmpeg-release-amd64-static.tar.xz /app/
COPY human-segmentation /app/human-segmentation
COPY requirements.txt /app/
# ---------------- Static FFmpeg ----------------
RUN tar xJf /app/ffmpeg-release-amd64-static.tar.xz \
-C /usr/local/bin \
--strip-components=1 \
--wildcards '*/ffmpeg' '*/ffprobe' && \
chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe
# ---------------- Human Segmentation Environment ----------------
RUN conda create -n hum-seg python=3.10.12 -y && \
conda run -n hum-seg pip install --upgrade pip setuptools wheel setuptools_scm && \
conda run -n hum-seg pip install vispy==0.14.1 --only-binary :all: && \
conda run -n hum-seg pip install -r /app/human-segmentation/requirements.txt && \
conda run -n hum-seg pip install /app/human-segmentation/lang_sam/ --no-build-isolation && \
conda run -n hum-seg pip install git+https://github.com/facebookresearch/detectron2.git --no-build-isolation
# ---------------- EPiC Environment ----------------
RUN conda create -n epic python=3.10 -y && \
conda run -n epic pip install --upgrade pip && \
conda run -n epic pip install -r /app/requirements.txt && \
conda run -n epic pip install gradio==5.46.1 && \
conda run -n epic pip install fastapi uvicorn[standard]
# ---------------- Default User & CMD ----------------
COPY . /app
RUN mkdir -p /data/pretrained /app/hf_cache /.cache/gdown && \
chmod -R 777 /app /root /.cache && \
chown -R 1000:1000 /app
EXPOSE 7860 7890 7862
USER 1000
CMD ["conda", "run", "--no-capture-output", "-n", "epic", "python", "gradio_server.py"]