- new photo-ai service: FastAPI + Real-ESRGAN x2plus on CPU, internal only - async job queue in server (POST enhance-ai / GET status), 5min timeout, sequential processing - keep original photo backup (entries.photo_original_path, uploads/.originals), restore-original endpoint - UI: AI button and restore-original button in enhance modal - db: photo_original_path column (init.sql, migration.sql, runtime ensure)
27 lines
811 B
Docker
27 lines
811 B
Docker
FROM python:3.10-slim
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends libgl1 libglib2.0-0 && rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
|
|
|
|
RUN pip install --no-cache-dir realesrgan==0.3.0 fastapi "uvicorn[standard]" python-multipart opencv-python-headless numpy
|
|
|
|
RUN python - <<'EOF'
|
|
import basicsr, os
|
|
p = os.path.join(os.path.dirname(basicsr.__file__), 'data', 'degradations.py')
|
|
s = open(p).read()
|
|
s = s.replace('torchvision.transforms.functional_tensor', 'torchvision.transforms.functional')
|
|
open(p, 'w').write(s)
|
|
print('basicsr patch applied')
|
|
EOF
|
|
|
|
COPY app.py .
|
|
|
|
ENV MODEL_PATH=/models/RealESRGAN_x2plus.pth
|
|
|
|
VOLUME /models
|
|
|
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
|