lidavidsh/ml-sharp
1
1#!/bin/bash2# Sharp Web Interface - One-Click Launcher3# Double-click this file to start the Sharp web interface4 5# Change to the script's directory6cd "$(dirname "$0")"7 8ENV_NAME="sharp"9PYTHON_VERSION="3.13"10 11echo "======================================"12echo " Sharp 3D Prediction - Web Interface"13echo "======================================"14echo ""15 16# Check if conda is available17if ! command -v conda &> /dev/null; then18 echo "โ Conda is not installed or not in PATH."19 echo ""20 echo "Please install Miniconda or Anaconda first:"21 echo " https://docs.conda.io/en/latest/miniconda.html"22 echo ""23 read -p "Press Enter to exit..."24 exit 125fi26 27# Initialize conda for this shell session28eval "$(conda shell.bash hook)"29 30# Check if the environment exists31if ! conda env list | grep -q "^${ENV_NAME} "; then32 echo "๐ฆ Creating conda environment '${ENV_NAME}' with Python ${PYTHON_VERSION}..."33 conda create -n "$ENV_NAME" python="$PYTHON_VERSION" -y34 if [ $? -ne 0 ]; then35 echo "โ Failed to create conda environment."36 read -p "Press Enter to exit..."37 exit 138 fi39 echo "โ
Environment created."40 echo ""41fi42 43# Activate the environment44echo "๐ Activating conda environment '${ENV_NAME}'..."45conda activate "$ENV_NAME"46if [ $? -ne 0 ]; then47 echo "โ Failed to activate conda environment."48 read -p "Press Enter to exit..."49 exit 150fi51 52# Check if sharp is installed by trying to import it53echo "๐ Checking if dependencies are installed..."54if ! python -c "import sharp" 2>/dev/null; then55 echo "๐ฆ Installing project dependencies (this may take a few minutes)..."56 pip install -r requirements.txt57 if [ $? -ne 0 ]; then58 echo "โ Failed to install requirements."59 read -p "Press Enter to exit..."60 exit 161 fi62 echo "โ
Dependencies installed."63 echo ""64fi65 66# Check if web dependencies are installed67if ! python -c "import fastapi" 2>/dev/null; then68 echo "๐ฆ Installing web interface dependencies..."69 pip install -r src/sharp/web/requirements.txt70 if [ $? -ne 0 ]; then71 echo "โ Failed to install web requirements."72 read -p "Press Enter to exit..."73 exit 174 fi75 echo "โ
Web dependencies installed."76 echo ""77fi78 79echo "======================================"80echo "๐ Starting Sharp Web Interface..."81echo "======================================"82echo ""83echo "Open your browser and go to:"84echo ""85echo " ๐ http://localhost:8000"86echo ""87echo "Press Ctrl+C to stop the server."88echo ""89 90# Start the web server91python src/sharp/web/app.py92 93# Keep terminal open if server stops unexpectedly94read -p "Press Enter to exit..."95 