-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
64 lines (51 loc) · 1.74 KB
/
run.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
#!/bin/bash
##### SET FOLLOWING VARS #####
CONDA_DIR="/home/$USER/src/miniconda3"
SERVER_ADDR="0.0.0.0"
SERVER_PORT=7867
###### END OF VARIABLES ######
# source base conda env in this script's subshell
# https://github.com/conda/conda/issues/7980
source $CONDA_DIR/etc/profile.d/conda.sh
# set working dir to this script's location:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
INSTALL_DIR="$SCRIPT_DIR/Paints-UNDO"
CONDA_ENV_DIR="$SCRIPT_DIR/conda_env"
available() { command -v $1 >/dev/null; }
cd $SCRIPT_DIR
# check if miniconda already installed
if ! available conda; then
echo "miniconda is not yet installed. Install it first."
exit 0
fi
# check if conda env already exists, create if not yet done
if [ ! -d "$CONDA_ENV_DIR" ]; then
conda create --no-shortcuts -y -k --prefix "$CONDA_ENV_DIR" python=3.10
fi
# confirm if conda env is actually created
if [ ! -f "$CONDA_ENV_DIR/bin/python" ]; then
echo "python is not found in $CONDA_ENV_DIR/bin"
echo "exiting."
exit 0
fi
# activate conda env
conda activate $CONDA_ENV_DIR || echo "Miniconda hook not found."
# check if install dir already exists
if [ ! -d "$INSTALL_DIR" ]; then
git clone https://github.com/lllyasviel/Paints-UNDO.git
cd Paints-UNDO
pip install xformers
pip install -r requirements.txt
sed -i -e "s/server_name='0.0.0.0'/ /" gradio_app.py # need to remove this so we can set via env var below
fi
cd $SCRIPT_DIR/Paints-UNDO
# launch
export GRADIO_SERVER_NAME=$SERVER_ADDR
export GRADIO_SERVER_PORT=$SERVER_PORT
if [ -n "${RUNNING_IN_SYSTEMD}" ]; then
echo "Running inside systemd"
python gradio_app.py 2>&1 | systemd-cat -t "paints-gradio"
else
echo "Running outside systemd"
python gradio_app.py
fi