Spaces:
Sleeping
Sleeping
| FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # System dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.10 python3.10-venv python3-pip python3.10-dev \ | |
| git git-lfs ffmpeg gcc \ | |
| libgl1 libglib2.0-0 libsm6 libxrender1 libxext6 libsndfile1 \ | |
| && git lfs install \ | |
| && ln -sf /usr/bin/python3.10 /usr/bin/python \ | |
| && ln -sf /usr/bin/pip3 /usr/bin/pip \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && pip install --no-cache-dir --upgrade pip | |
| # Create user (HF Spaces requirement) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| # ---- HEAVY INSTALLS (cached unless dependencies change) ---- | |
| # PyTorch with CUDA 12.1 (was previously pulled in by vllm — now explicit, no vllm bloat) | |
| RUN pip install --no-cache-dir \ | |
| torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \ | |
| --index-url https://download.pytorch.org/whl/cu121 | |
| # Clone FLOAT repo | |
| RUN git clone https://github.com/deepbrainai-research/float.git /app/float_repo | |
| # FLOAT dependencies + app requirements | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir \ | |
| "numpy<2" \ | |
| pyyaml opencv-python pandas tqdm matplotlib flow-vis librosa \ | |
| "transformers==4.46.3" "tokenizers>=0.20" "albumentations==1.4.15" "albucore==0.0.16" \ | |
| "torchdiffeq==0.2.5" "timm==1.0.9" "face_alignment==1.4.1" "av==12.0.0" \ | |
| scipy soundfile vosk websockets \ | |
| openai edge-tts cartesia \ | |
| && pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Create dirs | |
| RUN mkdir -p /tmp/videos /tmp/tts_output /tmp/lipsync_output | |
| # Pre-download FLOAT dependencies (wav2vec2 + emotion model) — cached in Docker layer | |
| RUN mkdir -p /app/checkpoints && \ | |
| python -c "from huggingface_hub import snapshot_download; \ | |
| print('Downloading wav2vec2-base-960h...'); \ | |
| snapshot_download('facebook/wav2vec2-base-960h', local_dir='/app/checkpoints/wav2vec2-base-960h'); \ | |
| print('Downloading emotion model...'); \ | |
| snapshot_download('r-f/wav2vec-english-speech-emotion-recognition', local_dir='/app/checkpoints/wav2vec-english-speech-emotion-recognition'); \ | |
| print('Models ready')" | |
| # Download Vosk small English model (~50MB, CPU-only STT) | |
| RUN python -c "import urllib.request, zipfile, os; \ | |
| url='https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip'; \ | |
| print('Downloading Vosk model...'); \ | |
| urllib.request.urlretrieve(url, '/tmp/vosk.zip'); \ | |
| zipfile.ZipFile('/tmp/vosk.zip').extractall('/app/'); \ | |
| os.rename('/app/vosk-model-small-en-us-0.15', '/app/vosk-model'); \ | |
| os.unlink('/tmp/vosk.zip'); \ | |
| print('Vosk model ready')" | |
| # Pre-warm face_alignment (downloads s3fd + 2DFAN4 into torch hub cache, ~180MB) | |
| ENV TORCH_HOME=/app/checkpoints/torch_hub | |
| RUN python -c "import face_alignment; face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, device='cpu')" | |
| # ---- APP CODE (only this rebuilds on code changes) ---- | |
| # cache bust v5 | |
| COPY --chown=user ./app.py ./llm.py ./tts.py ./float_lipsync.py ./idle_generator.py ./vosk_stt.py ./float_streamer.py /app/ | |
| # Copy avatar profiles (each has ref.png, persona.txt, idlevideos/) | |
| COPY --chown=user ./avatars/ /app/avatars/ | |
| # Copy checkpoints (float.pth) — baked in to avoid runtime downloads | |
| COPY --chown=user ./app/checkpoints/ /app/checkpoints/ | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |