Add caching support to gpt and stable-diffusion. - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
DIR commit a5defdc0144603b1c39bfbac8b31057ee2b597c3
DIR parent 4e5cb78d7021871cd8bd6e2081fbdb2062fcecdc
HTML Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Sat, 4 Jan 2025 12:16:20 +0100
Add caching support to gpt and stable-diffusion.
gpt down to 3s
Diffstat:
M gpt | 8 ++++++++
M stable-diffusion | 8 ++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
---
DIR diff --git a/gpt b/gpt
@@ -9,6 +9,14 @@ ggmlmodel="models/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf"
ggmlntokens="$((69 * 2))"
cd $ggmlbase
+if mountpoint -q /br/ai/tmp;
+then
+ ggmlbasename="$(basename "${ggmlmodel}")"
+ ggmltmppath="/br/ai/tmp/${ggmlbasename}"
+ [ ! -r "${ggmltmppath}" ] && cp "$ggmlmodel" /br/ai/tmp
+ [ -r "${ggmltmppath}" ] && ggmlmodel="${ggmltmppath}"
+fi
+
prompt="$1"
printf "%s\n" "${prompt}" \
| $ggmlbin -m $ggmlmodel -n $ggmlntokens \
DIR diff --git a/stable-diffusion b/stable-diffusion
@@ -14,6 +14,14 @@ sdnegative='nipples, busty, nude, lowres, (worst quality, low quality, normal qu
outputf="${1}"
shift 1
+if mountpoint -q /br/ai/tmp;
+then
+ sdbasename="$(basename "${sdmodel}")"
+ sdtmppath="/br/ai/tmp/${sdbasename}"
+ [ ! -r "${sdtmppath}" ] && cp "${sdmodel}" /br/ai/tmp
+ [ -r "${sttmppath}" ] && sdmodel="${sdtmppath}"
+fi
+
${sdcmd} --type f16 -m ${sdmodel} -o "${outputf}" -p "$@" -n "${sdnegative}" >/dev/null 2>&1
#${sdcmd} -m ${sdmodel} -o "${outputf}" -p "$@" -n "${sdnegative}" -v