-
Notifications
You must be signed in to change notification settings - Fork 4
/
sdcpp_webui.sh
executable file
·69 lines (61 loc) · 1.86 KB
/
sdcpp_webui.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
#!/usr/bin/env bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR"
help_print() {
echo ""
echo ""
echo "Usage: ./sdcpp_webui.sh [options]"
echo ""
echo "Options:"
echo " -h or --help: Show this help"
echo " --listen: Share sd.cpp-webui on your local network"
echo " --autostart: Open the UI automatically"
echo " --darkmode: Forces the UI to launch in dark mode"
echo ""
echo ""
exit 0
}
for arg in "$@"; do
case $arg in
--*'='*) shift; set -- "${arg%%=*}" "${arg#*=}" "$@"; continue;;
-h|--help) help_print;;
--listen) ;; # Passed to python
--autostart) ;; # Passed to python
--darkmode) ;; # Passed to python
*) echo "Unknown command parameter: $arg"; exit 1;;
esac
done
if [ ! -x "sd" ] && ! command -v "sd"; then
echo ""
echo ""
echo "Warning: 'sd' executable not found or doesn't have execute permissions."
echo "For the command to work place the stable-diffusion.cpp executable in the main sd.cpp-webui folder."
echo "The executable must be called 'sd'."
echo ""
echo ""
fi
if [ -d "venv" ]; then
echo "Virtual environment already exists."
else
echo "Creating virtual environment..."
python3 -m venv venv
echo "Virtual environment created."
fi
echo "Activating virtual environment..."
if [ -f "venv/bin/activate" ]; then
source venv/bin/activate
else
echo "Error: Virtual environment activation script not found."
exit 1
fi
echo "Virtual environment activated succesfully."
if pip freeze | grep -q -F -f requirements.txt; then
echo "Requirements are satisfied."
else
echo "Installing requirements..."
pip install -r requirements.txt
echo "Requirements installed."
fi
echo "Starting the WebUI..."
python3 sdcpp_webui.py $@