homework_5_docker / Dockerfile
De4u's picture
Fix startup: CPU-only torch, lazy load, preload weights in build
1a8a424 verified
Raw
History Blame Contribute Delete
921 Bytes
# rebuild: CPU torch + lazy model load
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
# CPU-only torch (~200 MB вместо ~2 GB с CUDA) — критично для free HF Spaces
RUN pip install --no-cache-dir torch==2.2.2 --index-url https://download.pytorch.org/whl/cpu \
&& pip install --no-cache-dir -r requirements.txt
ENV MODEL_REPO_ID=De4u/cyclegan-models
# Скачиваем веса на этапе сборки, чтобы старт приложения был мгновенным
RUN python -c "from huggingface_hub import hf_hub_download; \
repo='De4u/cyclegan-models'; \
[hf_hub_download(repo, f) for f in ('cyclegan_export.pt', 'cyclegan_export_monet.pt')]"
COPY app.py .
EXPOSE 7860
CMD ["streamlit", "run", "app.py", \
"--server.port=7860", \
"--server.address=0.0.0.0", \
"--server.headless=true", \
"--browser.gatherUsageStats=false"]