pip install requests
pip install tqdm
sudo apt update
sudo apt install software-properties-common --yes
sudo apt install git-lfs --yes
sudo apt install ffmpeg --yes
git lfs install

sudo apt update --yes

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda-repo-ubuntu2204-12-4-local_12.4.0-550.54.14-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-12-4-local_12.4.0-550.54.14-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-4-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-4

sudo echo 'export PATH=/usr/local/cuda-12.4/bin:$PATH' >> /etc/environment
sudo echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH' >> /etc/environment

source /etc/environment

# Verify CUDA installation
nvcc --version

sudo apt-get -y install cudnn9-cuda-12

git clone https://github.com/SECourses/LivePortrait

cd LivePortrait

python3 -m venv venv

source ./venv/bin/activate

echo "Installing requirements"

pip install -r requirements.txt

echo "Downloading models from HF"

python3 HF_model_downloader.py

sudo apt update --yes
sudo apt install gcc-11 g++-11 --yes
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 110
sudo update-alternatives --set gcc /usr/bin/gcc-11
sudo update-alternatives --set g++ /usr/bin/g++-11

cd src/utils/dependencies/XPose/models/UniPose/ops
python3 setup.py build install

# Show completion message
echo "Virtual environment made and installed properly"

# Keep the terminal open
read -p "Press Enter to continue..."
