# Hugging Face Docker Space: API and GPU worker only. The web/ frontend deploys separately. # README.md declares sdk: docker and app_port: 7860. FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1 \ STORAGE_ROOT=/home/mod/data HF_HOME=/home/mod/data/huggingface \ APP_ENV=testing WORKER_CONCURRENCY=1 # fonts-dejavu-core is the caption font; sox is needed by qwen-tts. RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg git sox fonts-dejavu-core && rm -rf /var/lib/apt/lists/* WORKDIR /opt/mod COPY requirements.txt requirements-gpu.txt ./ RUN pip install -r requirements-gpu.txt && pip check RUN useradd -u 1000 -m mod && mkdir -p /home/mod/data && chown mod:mod /home/mod/data # Talking-head model. It has no importable API and pins an older torch, so it gets its own # checkout and virtualenv; app/providers/talking.py runs it as a subprocess. ARG INFINITETALK_COMMIT=50aa0a94184315407a991ae804d9b58d6d311ba8 RUN git clone https://github.com/MeiGen-AI/InfiniteTalk /opt/infinitetalk \ && git -C /opt/infinitetalk checkout -q $INFINITETALK_COMMIT \ # Upstream targets Python 3.10; this unused import no longer exists in 3.11. && sed -i '/^from inspect import ArgSpec$/d' /opt/infinitetalk/wan/multitalk.py \ && python -m venv /opt/infinitetalk/venv \ && /opt/infinitetalk/venv/bin/pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 xformers==0.0.28 \ --index-url https://download.pytorch.org/whl/cu121 \ # Its requirements are unpinned and today's releases need a newer torch, so resolve # everything as of the model's release date. && pip install uv==0.8.13 \ && uv pip install --python /opt/infinitetalk/venv/bin/python --exclude-newer 2025-09-01 \ -r /opt/infinitetalk/requirements.txt librosa soundfile "misaki[en]" diffusers==0.34.0 transformers==4.52.4 distvae==0.0.0b5 kokoro \ # The model asserts flash-attention is present; this image has no compiler, so use the prebuilt wheel. && /opt/infinitetalk/venv/bin/pip install --no-deps \ "https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp311-cp311-linux_x86_64.whl" \ && chown -R mod:mod /opt/infinitetalk # BE: FastAPI routes, background GPU worker and model configuration. COPY --chown=mod:mod app app COPY --chown=mod:mod config config USER mod EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:7860/health/ready', timeout=4)" # One server process owns the configurable inference worker pool. CMD ["uvicorn", "app.main:create_app", "--factory", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--no-access-log"]