CoolFace
Apppublic

Tresor26/Coffee-beans-classification

sourceHugging Facemitupdated 2mo agoView on Hugging Face
1likes
start.sh44 linesDownload Raw Back to docker
1#!/usr/bin/env bash2set -e3 4# Nothing is computed here on purpose — every second spent before nginx binds5# :7860 is a second the Space shows "Starting" with no UI.6#7#   - data/insights.json is committed (built from the full 8,000-image set, so8#     it cannot be regenerated from the committed sample without contradicting9#     its own interpretation text).10#   - The champion is registered at image build time; see Dockerfile.space.11#   - scripts/download_data.py is deliberately not run: the baked baseline was12#     scored against data/test, and pulling the full dataset at boot would swing13#     config.test_dir() over to data/full/test, leaving the gate comparing the14#     champion and its candidates on two different eval slices.15 16uvicorn api.main:app --host 127.0.0.1 --port 8000 --workers 1 &17API_PID=$!18 19# fileWatcherType none: nothing edits source at runtime in a container, so20# hot-reload only costs inotify watches. (This is not what fixed the UI21# segfault — that was pyarrow; see requirements.txt.)22# XSRF/CORS off: a Space is served from <name>.hf.space but embedded in an23# iframe on huggingface.co, so the cross-site XSRF cookie never reaches24# streamlit and every POST to /_stcore/upload_file comes back 403 — which25# breaks both the bean uploader and the retraining ZIP upload. Only the Space26# needs this; served directly (docker-compose on :8090) the origin matches and27# the default protection works, so it stays on there.28streamlit run ui/app.py \29    --server.port 8501 \30    --server.address 127.0.0.1 \31    --server.headless true \32    --server.fileWatcherType none \33    --server.enableXsrfProtection false \34    --server.enableCORS false \35    --browser.gatherUsageStats false &36UI_PID=$!37 38nginx -c /app/docker/nginx.space.conf -g 'daemon off;' &39NGINX_PID=$!40 41# If any process dies, take the container down so the Space restarts it.42wait -n $API_PID $UI_PID $NGINX_PID43exit $?44