Skip to content

Instantly share code, notes, and snippets.

@sksat
Last active October 12, 2022 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sksat/9cd10d2fece3a0a1f411a0345cd84742 to your computer and use it in GitHub Desktop.
Save sksat/9cd10d2fece3a0a1f411a0345cd84742 to your computer and use it in GitHub Desktop.
濁流(0.5%記念)
#!/bin/bash
# data storage
DISCORD_WEBHOOK="https://discord.com/api/webhooks/*****"
# Web browser is best useful tool
TOKEN=""
INPUT="{{{{masterpiece}}}},UnrealEngine"
UC="worst quality, low quality, normal quality"
SEED="$(shuf -i 1-4294967295 -n 1)"
JSON=$(cat <<EOS
{
"input": "$INPUT",
"model": "nai-diffusion",
"parameters": {
"width":512,
"height":768,
"scale":11,
"sampler":"k_euler_ancestral",
"steps":28,
"seed": $SEED,
"n_samples":1,
"ucPreset":0,
"uc": "$UC"
}
}
EOS
)
curl 'https://api.novelai.net/ai/generate-image' -X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" \
--data-raw "$JSON" --raw -o "${SEED}-tmp"
head -n 2 "${SEED}-tmp"
tail -n 2 "${SEED}-tmp" > "${SEED}-tmp2"
sed -i -e 's/data://' "${SEED}-tmp2"
cat "${SEED}-tmp2" | base64 -d > "${SEED}.png"
rm "${SEED}-tmp" "${SEED}-tmp2"
curl --silent -H "Content-Type: multipart/form-data" -F "file=@${SEED}.png" "$DISCORD_WEBHOOK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment