forked from IAHispano/Applio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-install.sh
85 lines (81 loc) · 3.06 KB
/
run-install.sh
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
#!/bin/sh
printf "\033]0;Installer\007"
clear
# rm *.bat
# Function to create or activate a virtual environment
prepare_install() {
if [ -d ".venv" ]; then
echo "Venv found. This implies Applio has been already installed or this is a broken install"
printf "Do you want to execute run-applio.sh? (Y/N): " >&2
read -r r
r=$(echo "$r" | tr '[:upper:]' '[:lower:]')
if [ "$r" = "y" ]; then
./run-applio.sh && exit 1
else
echo "Ok! The installation will continue. Good luck!"
fi
. .venv/bin/activate
else
echo "Creating venv..."
requirements_file="requirements.txt"
echo "Checking if python exists"
if command -v python3.10 > /dev/null 2>&1; then
py=$(which python3.10)
echo "Using python3.10"
else
if python --version | grep -qE "3\.(7|8|9|10)\."; then
py=$(which python)
echo "Using python"
else
echo "Please install Python3 or 3.10 manually."
exit 1
fi
fi
$py -m venv .venv
. .venv/bin/activate
echo "Installing pip version less than 24.1..."
python -m pip install "pip<24.1"
echo
echo "Installing Applio dependencies..."
python -m pip install -r requirements.txt
python -m pip uninstall torch torchvision torchaudio -y
python -m pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu121
finish
fi
}
# Function to finish installation (this should install missing dependencies)
finish() {
# Check if required packages are installed and install them if not
if [ -f "${requirements_file}" ]; then
installed_packages=$(python -m pip freeze)
while IFS= read -r package; do
expr "${package}" : "^#.*" > /dev/null && continue
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
echo "${package_name} not found. Attempting to install..."
python -m pip install --upgrade "${package}"
fi
done < "${requirements_file}"
else
echo "${requirements_file} not found. Please ensure the requirements file with required packages exists."
exit 1
fi
clear
echo "Applio has been successfully downloaded. Run the file run-applio.sh to run the web interface!"
exit 0
}
# Loop to the main menu
if [ "$(uname)" = "Darwin" ]; then
if ! command -v brew >/dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
brew install python@3.10
export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
fi
elif [ "$(uname)" != "Linux" ]; then
echo "Unsupported operating system. Are you using Windows...?"
echo "If yes, use the batch (.bat) file instead of this one!"
exit 1
fi
prepare_install