File size: 1,976 Bytes
bfc6d2a 1f5895b bfc6d2a | 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | # M1c MuQ L9-12 Inference Handler
# HuggingFace Inference Endpoints container for piano performance analysis
FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04
# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3.11 \
python3.11-venv \
ffmpeg \
libsndfile1 \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set Python 3.11 as default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"
WORKDIR /app
# Install Python dependencies with uv
COPY requirements.txt .
RUN uv pip install --system --no-cache -r requirements.txt
# Pre-download HuggingFace models (cached in image)
# MuQ only
RUN python3 -c "\
print('Downloading MuQ-large-msd-iter...'); \
from muq import MuQ; \
MuQ.from_pretrained('OpenMuQ/MuQ-large-msd-iter'); \
print('Done!'); \
"
# Pre-download ByteDance AMT model weights (REQUIRED for cold start performance)
# device='cpu' is correct -- no GPU during Docker build. Constructor downloads weights only.
RUN python3 -c "\
print('Downloading ByteDance piano transcription model...'); \
from piano_transcription_inference import PianoTranscription; \
PianoTranscription(device='cpu'); \
print('Done!'); \
"
# Copy application code
COPY constants.py .
COPY handler.py .
COPY models/ ./models/
COPY preprocessing/ ./preprocessing/
# Create checkpoints directory structure
RUN mkdir -p /app/checkpoints/fold0 /app/checkpoints/fold1 /app/checkpoints/fold2 /app/checkpoints/fold3
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
ENV HF_HOME=/app/.cache/huggingface
# HuggingFace Inference Endpoints expects handler.py
# The EndpointHandler class will be automatically detected
|