#!/usr/bin/env bash # One-click start on macOS / Linux: the first run installs everything (10-20 min), later runs start in seconds. # bash start_mac_linux.sh set -e cd "$(dirname "$0")" if ! { [ -x venv/bin/python ] && venv/bin/python -c "import gradio, torch, transformers, timm" >/dev/null 2>&1; }; then PY="" for c in python3.11 python3 python; do if command -v "$c" >/dev/null 2>&1 && "$c" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)'; then PY="$c"; break; fi done if [ -z "$PY" ]; then echo "Python 3.10 or newer was not found. Install Python 3.11 from https://www.python.org/downloads/ and run this again."; exit 1; fi echo "First run: setting up. This downloads about 3 GB and takes 10-20 minutes." [ -x venv/bin/python ] || "$PY" -m venv venv venv/bin/python -m pip install --upgrade pip # On Linux the standard PyTorch package already includes NVIDIA GPU support; on a Mac the app runs on the processor. venv/bin/python -m pip install -r requirements.txt gradio==6.31.0 fi echo "Starting the app. Your browser opens when it is ready. Press Ctrl+C to stop." exec venv/bin/python app.py --open "$@"