masterofaudio2077's picture
switch to tf backend
55cc941
Raw
History Blame Contribute Delete
1.45 kB
# Hugging Face Space — Docker SDK
# FastAPI latent-diffusion server (DC-AE + distilled TinyCLIP + from-scratch
# UNet) on the Keras TensorFlow CPU backend (graph-compiled UNet), port 7860.
FROM python:3.12-slim
# OpenMP runtime for tensorflow; slim images don't ship it. git is needed to
# pip-install the keras-hub fork from GitHub.
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 git \
&& rm -rf /var/lib/apt/lists/*
# HF Spaces runs the container as a non-root user with UID 1000.
# Create it so model/tokenizer caches land in a writable home dir.
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
# caches for keras / keras-hub / HF downloads + the Kaggle presets
KERAS_HOME=/home/user/.keras \
HF_HOME=/home/user/.cache/huggingface \
PRESET_CACHE=/home/user/.cache/ldm_presets \
# Keras runs on the TensorFlow CPU backend (graph-compiled UNet); quiet TF's
# startup logging.
KERAS_BACKEND=tensorflow \
TF_CPP_MIN_LOG_LEVEL=2
WORKDIR $HOME/app
# Install deps first so this layer caches across code changes. TensorFlow (CPU)
# is the compute backend, so no torch wheel is needed.
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# App code + sprites + static (gallery images).
COPY --chown=user . .
EXPOSE 7860
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]