summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--krebs/2configs/reaktor2.nix6
-rw-r--r--krebs/5pkgs/simple/stable-generate/default.nix64
2 files changed, 18 insertions, 52 deletions
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index 13b59fa82..e1e3b7670 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -64,8 +64,7 @@ let
pkgs.curl
pkgs.stable-generate
]}
- stable_url=$(stable-generate "$@")
- paste_url=$(curl -Ss "$stable_url" |
+ paste_url=$(stable-generate "$@" |
curl -Ss http://p.r --data-binary @- |
tail -1
)
@@ -87,8 +86,7 @@ let
pkgs.stable-generate
]}
case $_msgtarget in \#*)
- stable_url=$(stable-generate "$@")
- paste_url=$(curl -Ss "$stable_url" |
+ paste_url=$(stable-generate "$@" |
curl -Ss https://p.krebsco.de --data-binary @- |
tail -1
)
diff --git a/krebs/5pkgs/simple/stable-generate/default.nix b/krebs/5pkgs/simple/stable-generate/default.nix
index fac261613..dc9c826f9 100644
--- a/krebs/5pkgs/simple/stable-generate/default.nix
+++ b/krebs/5pkgs/simple/stable-generate/default.nix
@@ -1,64 +1,32 @@
{ pkgs, lib, ... }:
-pkgs.writers.writeDashBin "stable-generate" ''
+pkgs.writers.writeBashBin "stable-generate" ''
set -efu
export PATH=${lib.makeBinPath [
+ pkgs.coreutils
pkgs.curl
pkgs.jq
]}
STABLE_URL=''${STABLE_URL:-http://stable-confusion.r}
- PAYLOAD=$(jq -cn --arg query "$*" '{fn_index: 51, data: [
- $query,
- "",
- "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"}')
+ PAYLOAD=$(jq -cn --arg prompt "$*" '{
+ prompt: $prompt
+ }')
- data=$(curl -Ssf "$STABLE_URL/run/predict/" \
+ filename=$(mktemp)
+ curl -Ssf "$STABLE_URL/sdapi/v1/txt2img" \
-X POST \
--Header 'Content-Type: application/json' \
- --data "$PAYLOAD"
- )
- export data
+ --data "$PAYLOAD" |
+ jq -r '.images[0]' |
+ base64 --decode > "$filename"
- filename=$(jq -rn 'env.data | fromjson.data[0][0].name')
-
- echo "$STABLE_URL/file=$filename"
+ if test -t 1; then
+ echo "$filename"
+ else
+ cat "$filename"
+ rm "$filename"
+ fi
''