-
Notifications
You must be signed in to change notification settings - Fork 16
/
UVR5-UI-installer.sh
105 lines (87 loc) · 2.68 KB
/
UVR5-UI-installer.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
echo "Welcome to the UVR5 UI Installer!"
echo
INSTALL_DIR="$(pwd)"
MINICONDA_DIR="$HOME/miniconda3"
ENV_DIR="$INSTALL_DIR/env"
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py310_24.9.2-0-Linux-x86_64.sh"
CONDA_EXE="$MINICONDA_DIR/bin/conda"
echo -e "\e]2;UVR5 UI Installer\a"
check_privileges() {
if [ "$(id -u)" -eq 0 ]; then
echo "ERROR: This script must not be run with sudo/root privileges"
echo "Please run it as a normal user without sudo"
read -p "Press Enter to exit..."
exit 1
fi
echo "The script is running without root privileges, continuing..."
echo
}
cleanup() {
echo "Cleaning up unnecessary files..."
rm -f *.bat
echo "Cleanup complete"
echo
}
install_miniconda() {
if [ -f "$CONDA_EXE" ]; then
echo "Miniconda already installed. Skipping installation..."
return 0
fi
echo "Miniconda not found. Starting download and installation..."
if ! wget "$MINICONDA_URL" -O miniconda.sh; then
echo "Download failed. Please check your internet connection and try again"
exit 1
fi
bash miniconda.sh -b -p "$MINICONDA_DIR"
if [ $? -ne 0 ]; then
echo "Miniconda installation failed"
exit 1
fi
rm miniconda.sh
echo "Miniconda installation complete"
echo
export PATH="$MINICONDA_DIR/condabin:$PATH"
echo "Added Miniconda to PATH"
}
create_conda_env() {
echo "Creating Conda environment..."
"$MINICONDA_DIR/condabin/conda" create --no-shortcuts -y -k --prefix "$ENV_DIR" python=3.10.12
if [ $? -ne 0 ]; then
echo "Failed to create conda environment"
exit 1
fi
echo "Conda environment created successfully"
echo
if [ -f "$ENV_DIR/bin/python" ]; then
echo "Installing specific pip version..."
"$ENV_DIR/bin/python" -m pip install "pip==24.1.2"
if [ $? -ne 0 ]; then
echo "Failed to install pip"
exit 1
fi
echo "Pip installation complete"
echo
fi
}
install_dependencies() {
echo "Installing dependencies..."
source "$MINICONDA_DIR/etc/profile.d/conda.sh"
conda activate "$ENV_DIR" || exit 1
pip install -r "$INSTALL_DIR/requirements.txt" || exit 1
pip uninstall torch torchvision -y || exit 1
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121 || exit 1
conda deactivate
echo "Dependencies installation complete"
echo
}
set -e
check_privileges
cleanup
install_miniconda
create_conda_env
install_dependencies
echo "UVR5 UI has been installed successfully!"
echo "To start UVR5 UI, please run 'run-UVR5-UI.sh'"
read -p "Press Enter to exit..."
chmod +x "$0"