|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
|
|
|
|
|
echo "Video Action Recognition - Numpy Fix Script" |
|
|
echo "============================================" |
|
|
echo "Working directory: $SCRIPT_DIR" |
|
|
echo "" |
|
|
|
|
|
|
|
|
if [[ ! -f "$SCRIPT_DIR/requirements.txt" ]]; then |
|
|
echo "β Error: requirements.txt not found" |
|
|
echo "Make sure you're running this script from the Video Action Recognition directory" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
if [[ ! -d "$SCRIPT_DIR/.venv" ]]; then |
|
|
echo "β Error: Virtual environment not found" |
|
|
echo "Creating virtual environment..." |
|
|
cd "$SCRIPT_DIR" |
|
|
python3 -m venv .venv |
|
|
if [[ $? -ne 0 ]]; then |
|
|
echo "β Failed to create virtual environment" |
|
|
exit 1 |
|
|
fi |
|
|
echo "β
Virtual environment created" |
|
|
fi |
|
|
|
|
|
|
|
|
echo "Activating virtual environment..." |
|
|
source "$SCRIPT_DIR/.venv/bin/activate" |
|
|
|
|
|
if [[ "$VIRTUAL_ENV" == "" ]]; then |
|
|
echo "β Failed to activate virtual environment" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
echo "β
Virtual environment activated: $VIRTUAL_ENV" |
|
|
|
|
|
|
|
|
echo "" |
|
|
echo "Upgrading pip..." |
|
|
python -m pip install --upgrade pip |
|
|
|
|
|
|
|
|
echo "" |
|
|
echo "Checking current numpy status..." |
|
|
python -c "import numpy; print(f'β
Numpy version: {numpy.__version__}')" 2>/dev/null |
|
|
NUMPY_STATUS=$? |
|
|
|
|
|
if [[ $NUMPY_STATUS -eq 0 ]]; then |
|
|
echo "β
Numpy is already working" |
|
|
else |
|
|
echo "β Numpy not available, fixing..." |
|
|
|
|
|
|
|
|
echo "Force reinstalling numpy..." |
|
|
python -m pip install --force-reinstall --no-cache-dir "numpy>=1.24.0" |
|
|
|
|
|
|
|
|
echo "Installing/updating other dependencies..." |
|
|
python -m pip install --upgrade "Pillow>=10.0.0" |
|
|
python -m pip install --upgrade "opencv-python>=4.9.0" |
|
|
|
|
|
|
|
|
echo "Installing from requirements.txt..." |
|
|
python -m pip install -r "$SCRIPT_DIR/requirements.txt" |
|
|
fi |
|
|
|
|
|
|
|
|
echo "" |
|
|
echo "Testing final configuration..." |
|
|
python -c " |
|
|
try: |
|
|
import numpy as np |
|
|
print(f'β
Numpy: {np.__version__}') |
|
|
|
|
|
import torch |
|
|
print(f'β
PyTorch: {torch.__version__}') |
|
|
|
|
|
from PIL import Image |
|
|
print('β
PIL: Available') |
|
|
|
|
|
import cv2 |
|
|
print(f'β
OpenCV: {cv2.__version__}') |
|
|
|
|
|
from transformers import AutoImageProcessor |
|
|
print('β
Transformers: Available') |
|
|
|
|
|
# Test the specific numpy operations used in video processing |
|
|
test_array = np.array([[[1, 2, 3], [4, 5, 6]]], dtype=np.float32) |
|
|
stacked = np.stack([test_array, test_array], axis=0) |
|
|
print(f'β
Numpy operations work: shape {stacked.shape}') |
|
|
|
|
|
print('') |
|
|
print('π All dependencies are working correctly!') |
|
|
|
|
|
except Exception as e: |
|
|
print(f'β Error: {e}') |
|
|
print('') |
|
|
print('β Some dependencies are still not working') |
|
|
exit(1) |
|
|
" |
|
|
|
|
|
if [[ $? -eq 0 ]]; then |
|
|
echo "" |
|
|
echo "β
Fix completed successfully!" |
|
|
echo "" |
|
|
echo "You can now run your app with:" |
|
|
echo " source .venv/bin/activate" |
|
|
echo " streamlit run app.py" |
|
|
echo "" |
|
|
echo "Or use the run script:" |
|
|
echo " ./run_app.sh" |
|
|
else |
|
|
echo "" |
|
|
echo "β Issues remain. Try these additional steps:" |
|
|
echo "1. Delete and recreate the virtual environment:" |
|
|
echo " rm -rf .venv" |
|
|
echo " python3 -m venv .venv" |
|
|
echo " source .venv/bin/activate" |
|
|
echo " pip install -r requirements.txt" |
|
|
echo "" |
|
|
echo "2. Check your Python installation" |
|
|
echo "3. Try using a different Python version" |
|
|
fi |
|
|
|