diff options
author | lassulus <lassulus@lassul.us> | 2022-12-13 15:39:44 +0100 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2022-12-13 15:39:44 +0100 |
commit | 2c253d51709c7e2957a7028e409688f7d14ef757 (patch) | |
tree | 36aed0d4dac49d6189e298e2db7687c7e8878a51 /krebs | |
parent | 248d3f592adbe3f7567c25f8f7efc1045b25e216 (diff) |
pkgs.stable-interrogate: init
Diffstat (limited to 'krebs')
-rw-r--r-- | krebs/5pkgs/simple/stable-interrogate/default.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/stable-interrogate/default.nix b/krebs/5pkgs/simple/stable-interrogate/default.nix new file mode 100644 index 000000000..7cc7509eb --- /dev/null +++ b/krebs/5pkgs/simple/stable-interrogate/default.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, ... }: + +pkgs.writers.writeBashBin "stable-interrogate" '' + set -xefu + set -o pipefail + + export PATH=${lib.makeBinPath [ + pkgs.coreutils + pkgs.curl + pkgs.jq + ]} + + STABLE_URL=''${STABLE_URL:-http://stable-confusion.r} + + (if test -e "$1"; then + cat "$1" + elif [[ "$1" =~ ^https?: ]]; then + curl -fSs "$1" + else + echo 'input not recognized' >&2 + exit 1 + fi) | base64 | + jq -Rsrc '{ + image: ., + model: "deepdanbooru", # clip is broken right now :( + }' | + curl -Ssf "$STABLE_URL/sdapi/v1/interrogate" \ + -X POST -H 'Content-Type: application/json' -d @- | + jq -r '.caption' +'' |