pawansharmaaaa / Lip_Wise

Orchestrating AI for stunning lip-synced videos. Effortless workflow, exceptional results, all in one place.
Apache License 2.0
56 stars 14 forks source link

setup.sh #12

Open JuvenileLocksmith opened 3 months ago

JuvenileLocksmith commented 3 months ago
#!/bin/bash

# Helper function to check if a command exists
command_exists() {
    command -v "$1" &> /dev/null
}

# Install FFMPEG
os_name=$(uname -s)
echo "Operating system detected: $os_name"

# Check if ffmpeg is installed
if ! command_exists ffmpeg; then
    echo "FFmpeg is not installed. Installing now..."
    case "$os_name" in
        Linux*)
            distro=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
            if [[ $distro == *"Arch"* ]]; then
                sudo pacman -Sy ffmpeg --noconfirm
            elif [[ $distro == *"Ubuntu"* ]] || [[ $distro == *"Debian"* ]]; then
                sudo apt-get update
                sudo apt-get install ffmpeg -y
                sudo apt-get install python3-venv -y
            else
                echo "Unsupported Linux distribution: $distro"
                exit 1
            fi
            ;;
        *)
            echo "Unsupported operating system: $os_name"
            exit 1
            ;;
    esac
else
    echo "FFmpeg is already installed."
fi

# Check if CUDA is installed and accessible
if [ -z "$(ls /usr/local/cuda-*/bin/nvcc 2>/dev/null)" ]; then
    echo "CUDA is not installed or not properly configured."
    echo "Please install or configure CUDA."
    echo "CPU will be used for inference."
else
    cuda_version=$(/usr/local/cuda/bin/nvcc --version | grep release | sed 's/.*release //' | sed 's/,.*//')
    echo "CUDA version $cuda_version detected."
fi

# Create and activate a virtual environment
venv_dir=".lip-wise"
if [ ! -d "$venv_dir" ]; then
    python3 -m venv "$venv_dir"
fi
source "$venv_dir/bin/activate"

# Install Python packages
pip install -U pip
pip install -r requirements.txt

# Copy architecture files to the virtual environment
python_version=$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
arch_target_dir="$venv_dir/lib/python${python_version}/site-packages/basicsr/archs"

mkdir -p "$arch_target_dir"
cp archs/* "$arch_target_dir/"

# Run file_check.py
python ./helpers/file_check.py
pawansharmaaaa commented 2 months ago

Issue?