#!/bin/bash set -e # Load environment variables source .env # Check if we should run in UI or API mode if [ "$ENABLE_UI" = "true" ]; then echo "Starting Gradio UI with API backend..." exec python app.py --api-server & sleep 5 # Give the API server time to start exec python app.py elif [ "$API_ONLY" = "true" ]; then echo "Starting API server only..." exec gunicorn --bind 0.0.0.0:$PORT --workers 1 --timeout 300 "image_descriptor:app" else # Default behavior for Hugging Face Spaces: run both echo "Starting service in Hugging Face Spaces mode..." exec python app.py fi