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