Spaces:
Paused
Paused
File size: 1,366 Bytes
a34a6d1 | 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 | FROM python:3.11-slim
# Prevent python from buffering stdout/stderr
ENV PYTHONUNBUFFERED=1 \
PORT=7860
WORKDIR /app
# Install system dependencies (build-essential, git, libgl for image libs)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY . .
# Ensure models directory has weights (download if missing during build)
RUN python -c "
import urllib.request, os
os.makedirs('models', exist_ok=True)
models = {
'models/waifu2x_art_scale2x.onnx': 'https://huggingface.co/deepghs/waifu2x_onnx/resolve/main/20230131/onnx_models/cunet/art/scale2x.onnx',
'models/waifu2x_art_noise1_scale2x.onnx': 'https://huggingface.co/deepghs/waifu2x_onnx/resolve/main/20230131/onnx_models/cunet/art/noise1_scale2x.onnx'
}
for dest, url in models.items():
if not os.path.exists(dest):
print('Downloading', dest)
urllib.request.urlretrieve(url, dest)
"
# Set non-root permissions for Hugging Face Spaces
RUN useradd -m -u 1000 appuser && \
chown -R appuser:appuser /app
USER appuser
EXPOSE 7860
# Launch FastAPI server
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|