stable-generate: use new api
This commit is contained in:
parent
3884243448
commit
1a32b111d1
@ -1,64 +1,32 @@
|
|||||||
{ pkgs, lib, ... }:
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
pkgs.writers.writeDashBin "stable-generate" ''
|
pkgs.writers.writeBashBin "stable-generate" ''
|
||||||
set -efu
|
set -efu
|
||||||
|
|
||||||
export PATH=${lib.makeBinPath [
|
export PATH=${lib.makeBinPath [
|
||||||
|
pkgs.coreutils
|
||||||
pkgs.curl
|
pkgs.curl
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
]}
|
]}
|
||||||
|
|
||||||
STABLE_URL=''${STABLE_URL:-http://stable-confusion.r}
|
STABLE_URL=''${STABLE_URL:-http://stable-confusion.r}
|
||||||
|
|
||||||
PAYLOAD=$(jq -cn --arg query "$*" '{fn_index: 51, data: [
|
PAYLOAD=$(jq -cn --arg prompt "$*" '{
|
||||||
$query,
|
prompt: $prompt
|
||||||
"",
|
}')
|
||||||
"None",
|
|
||||||
"None",
|
|
||||||
20, # sampling steps
|
|
||||||
"Euler a", # sampling method
|
|
||||||
false, # restore faces
|
|
||||||
false,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
7,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
false,
|
|
||||||
512, #probably resolution
|
|
||||||
512, #probably resolution
|
|
||||||
false,
|
|
||||||
0.7,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
"None",
|
|
||||||
"",
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"Seed",
|
|
||||||
"",
|
|
||||||
"Nothing",
|
|
||||||
"",
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
null,
|
|
||||||
"",
|
|
||||||
""], session_hash: "hello_this_is_dog"}')
|
|
||||||
|
|
||||||
data=$(curl -Ssf "$STABLE_URL/run/predict/" \
|
filename=$(mktemp)
|
||||||
|
curl -Ssf "$STABLE_URL/sdapi/v1/txt2img" \
|
||||||
-X POST \
|
-X POST \
|
||||||
--Header 'Content-Type: application/json' \
|
--Header 'Content-Type: application/json' \
|
||||||
--data "$PAYLOAD"
|
--data "$PAYLOAD" |
|
||||||
)
|
jq -r '.images[0]' |
|
||||||
export data
|
base64 --decode > "$filename"
|
||||||
|
|
||||||
filename=$(jq -rn 'env.data | fromjson.data[0][0].name')
|
if test -t 1; then
|
||||||
|
echo "$filename"
|
||||||
echo "$STABLE_URL/file=$filename"
|
else
|
||||||
|
cat "$filename"
|
||||||
|
rm "$filename"
|
||||||
|
fi
|
||||||
''
|
''
|
||||||
|
Loading…
Reference in New Issue
Block a user