line-detection / setup.sh
AKA Math
Update demo
9a67d72
Raw
History Blame Contribute Delete
2.44 kB
#!/bin/bash
# Setup script for local development
set -e
echo "πŸ”§ Setting up Hough Transform & RANSAC Line Detection Demo"
echo "=========================================================="
echo ""
# Check Python version
echo "🐍 Checking Python version..."
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
echo " Found Python $PYTHON_VERSION"
REQUIRED_VERSION="3.11"
if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
echo "⚠️ Warning: Python $REQUIRED_VERSION or higher is recommended."
fi
echo ""
# Check if uv is installed
if command -v uv &> /dev/null; then
echo "✨ uv package manager detected!"
USE_UV=true
else
echo "πŸ“¦ Using standard venv (install uv for faster setup: pip install uv)"
USE_UV=false
fi
echo ""
# Create virtual environment
if [ -d "venv" ]; then
echo "πŸ“¦ Virtual environment already exists."
read -p " Do you want to recreate it? (y/N): " RECREATE
if [ "$RECREATE" = "y" ] || [ "$RECREATE" = "Y" ]; then
echo " Removing old virtual environment..."
rm -rf venv
if [ "$USE_UV" = true ]; then
echo " Creating virtual environment with uv..."
uv venv
else
echo " Creating virtual environment..."
python3 -m venv .venv
fi
fi
else
if [ "$USE_UV" = true ]; then
echo "πŸ“¦ Creating virtual environment with uv..."
uv venv .venv
else
echo "πŸ“¦ Creating virtual environment..."
python3 -m venv .venv
fi
fi
# Activate virtual environment
echo "πŸ”§ Activating virtual environment..."
source .venv/bin/activate
# Install dependencies
if [ "$USE_UV" = true ]; then
echo "⚑ Installing dependencies with uv (fast!)..."
uv pip install -r requirements.txt
else
echo "⬆️ Upgrading pip..."
pip install --upgrade pip > /dev/null 2>&1
echo "πŸ“₯ Installing requirements..."
pip install -r requirements.txt
fi
echo ""
echo "βœ… Setup complete!"
echo ""
echo "πŸ“š Next steps:"
echo " 1. Run './run_simple.sh' to start the demo locally"
echo " 2. Or activate the environment: 'source venv/bin/activate'"
echo " 3. Then run: 'streamlit run app.py'"
echo ""
echo "πŸš€ To deploy to Hugging Face Spaces:"
echo " 1. Create a Space at https://huggingface.co/new-space"
echo " 2. Run './deploy.sh' and follow the prompts"