Repository navigation
Expand file tree
/
Copy pathrunner.sh
More file actions
executable file
·96 lines (76 loc) · 2.07 KB
/
Copy pathrunner.sh
File metadata and controls
executable file
·96 lines (76 loc) · 2.07 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
92
93
94
95
96
#!/bin/bash
set -e
bold=$(tput bold)
normal=$(tput sgr0)
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Include pashua.sh to be able to use the 2 functions defined in that file
# shellcheck source=/dev/null
source "$mydir/pashua.sh"
# Define what the dialog should be like
# Take a look at Pashua's Readme file for more info on the syntax
conf="
# Set window title
*.title = Welcome to Stable Diffusion Runner
# Prompt
tf.type = textbox
tf.label = Describe your idea
tf.width = 310
tf.height = 200
tf.mandatory = true
tf.tooltip = Write an idea, such as the description of a scene
# Add a samplingup menu
sampling.type = popup
sampling.label = Sampling steps
sampling.width = 310
sampling.option = 1
sampling.option = 10
sampling.option = 30
sampling.option = 50
sampling.default = 30
sampling.tooltip = How many sampling steps for PLMS?
# Add a cancel button with default label
cb.type = cancelbutton
cb.tooltip = Cancel and do not run
db.type = defaultbutton
db.label = Run
db.tooltip = Click to run
"
if [ -d '/Volumes/Pashua/Pashua.app' ]
then
# Looks like the Pashua disk image is mounted. Run from there.
customLocation='/Volumes/Pashua'
else
# Search for Pashua in the standard locations
customLocation=''
fi
locate_pashua "$customLocation"
pashua_run "$conf" "$customLocation"
echo "${tf:?}" > /dev/null
echo "${sampling:?}" > /dev/null
echo "${cb:?}" > /dev/null
if [[ "$cb" == "1" ]]
then
echo "Cancelled - Exit"
exit 130
fi
outdir=$(pwd)/../stable-diffusion-output
mkdir -p "$outdir"
pushd ../stable-diffusion || exit
# shellcheck source=/dev/null
source venv/bin/activate
python scripts/txt2img.py --prompt "$tf" --n_samples 1 --n_iter 1 --plms --ddim_steps "$sampling" --outdir "$outdir"
popd || exit
unset -v latest
for file in "$outdir"/*; do
[[ $file -nt $latest ]] && latest=$(realpath "$file")
done
unset -v metafile
metafile="$(dirname "$latest")/$(basename "$latest" png)txt"
touch "$metafile"
echo "$tf" >> "$metafile"
echo >> "$metafile"
echo "${bold}Proudly presenting${normal}"
cat "$metafile"
echo
echo "${bold}Image saved to $latest${normal}"
open "$latest"