Repository navigation
Expand file tree
/
Copy pathsdcpp_webui.sh
More file actions
executable file
·91 lines (80 loc) · 2.88 KB
/
Copy pathsdcpp_webui.sh
File metadata and controls
executable file
·91 lines (80 loc) · 2.88 KB
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
#!/usr/bin/env bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR"
print_help() {
cat << EOF
Usage: ./sdcpp_webui.sh [options]
Options:
-h or --help: Show this help
--server Enable stable-diffusion.cpp's server mode
--listen: Share sd.cpp-webui on your local network
--share Share sd.cpp-webui online with a link
--autostart: Open the UI automatically
--credentials: Enable password protection using credentials.json
Expected format: {"username1": "password1", "username2": "password2"}
--allow-insecure-dir: Allows the usage of external or linked directories based on config.json
--extensions Enable extensions (asks before installing their requirements)
EOF
exit "${1:-0}"
}
for arg in "$@"; do
case $arg in
-h|--help)
print_help
;;
--server)
SERVER_MODE=1
;;
--listen|--share|--autostart|--credentials|--allow-insecure-dir|--extensions)
;;
*)
printf "Error: Unknown command parameter: %s\n" "$arg" >&2
print_help 1
;;
esac
done
if [ "$SERVER_MODE" = 1 ]; then
if [ ! -x "sd-server" ] && ! command -v "sd-server" > /dev/null; then
echo "Error: '--server' flag was used, but the 'sd-server' executable was not found or is not executable."
echo "Please place the 'sd-server' executable in this folder or ensure it is in your PATH."
exit 1
fi
elif [ ! -x "sd-cli" ] && ! command -v "sd-cli" > /dev/null && \
[ ! -x "sd" ] && ! command -v "sd" > /dev/null; then
echo "Error: Neither 'sd-cli' nor 'sd' executables were found or they're not executable."
echo "Please place the 'sd-cli' or 'sd' executable in this folder or ensure it is in your PATH."
exit 1
fi
if [ ! -f "venv/bin/activate" ]; then
echo "Creating virtual environment..."
if ! python3 -m venv venv; then
echo "Error: failed to create the virtual environment."
exit 1
fi
fi
echo "Activating virtual environment..."
source "venv/bin/activate"
# Only installs when something is missing; pip's output is shown
if python3 check_requirements.py requirements.txt > /dev/null; then
echo "Requirements are installed."
else
echo "Some requirements are missing:"
python3 check_requirements.py requirements.txt || true
echo
echo "Installing the requirements..."
if ! pip install --disable-pip-version-check -r requirements.txt; then
echo "Error: failed to install the requirements."
exit 1
fi
if ! python3 check_requirements.py requirements.txt > /dev/null; then
echo "Error: the requirements are still not met."
exit 1
fi
fi
if [ $# -eq 0 ]; then
printf "\nStarting the WebUI...\n\n"
else
printf "\nStarting the WebUI with arguments: %s\n\n" "$*"
fi
python3 sdcpp_webui.py "$@"