File size: 2,505 Bytes
eb09c29 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
#!/bin/bash
# Script to properly run the Video Action Recognition Streamlit app
# This handles virtual environment activation and dependency checks
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "π¬ Video Action Recognition App"
echo "==============================="
echo "Working directory: $SCRIPT_DIR"
echo ""
# Change to the script directory
cd "$SCRIPT_DIR"
# Check if virtual environment exists
if [[ ! -d ".venv" ]]; then
echo "β Virtual environment not found"
echo "Creating virtual environment..."
python3 -m venv .venv
if [[ $? -ne 0 ]]; then
echo "β Failed to create virtual environment"
echo "Please ensure Python 3 is installed"
exit 1
fi
echo "β
Virtual environment created"
fi
# Activate virtual environment
echo "Activating virtual environment..."
source ".venv/bin/activate"
if [[ "$VIRTUAL_ENV" == "" ]]; then
echo "β Failed to activate virtual environment"
echo "Try running manually:"
echo " source .venv/bin/activate"
echo " streamlit run app.py"
exit 1
fi
echo "β
Virtual environment activated"
# Check if dependencies are installed
echo "Checking dependencies..."
python -c "import numpy, torch, transformers, streamlit, cv2" 2>/dev/null
if [[ $? -ne 0 ]]; then
echo "β οΈ Some dependencies missing, installing..."
pip install -r requirements.txt
if [[ $? -ne 0 ]]; then
echo "β Failed to install dependencies"
echo "Try running the fix script first: ./run_fix.sh"
exit 1
fi
fi
# Final dependency check
echo "Verifying numpy availability..."
python -c "
import numpy as np
print(f'β
Numpy version: {np.__version__}')
# Test the specific operations used in video processing
try:
test_array = np.array([[[1, 2, 3]]], dtype=np.float32)
stacked = np.stack([test_array, test_array], axis=0)
print('β
Numpy operations work correctly')
except Exception as e:
print(f'β Numpy operations failed: {e}')
print('Run the fix script: ./run_fix.sh')
exit(1)
" 2>/dev/null
if [[ $? -ne 0 ]]; then
echo "β Numpy issues detected"
echo "Please run the fix script first:"
echo " ./run_fix.sh"
exit 1
fi
echo ""
echo "π Starting Streamlit app..."
echo "The app will open in your default browser"
echo "Press Ctrl+C to stop the server"
echo ""
# Run the Streamlit app
streamlit run app.py
# Deactivate virtual environment when done
deactivate
|