summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/stable-generate/default.nix
blob: fac26161308b62209a2eaa19c12620e3258b34b0 (plain)
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
{ pkgs, lib, ... }:

pkgs.writers.writeDashBin "stable-generate" ''
  set -efu

  export PATH=${lib.makeBinPath [
    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"}')

  data=$(curl -Ssf "$STABLE_URL/run/predict/" \
    -X POST \
    --Header 'Content-Type: application/json' \
    --data "$PAYLOAD"
  )
  export data

  filename=$(jq -rn 'env.data | fromjson.data[0][0].name')

  echo "$STABLE_URL/file=$filename"
''