#! /usr/bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/ai alias ol="ollama list" alias ops="ollama ps" export AI_MODEL="llava:13b" img-ai-score () { local img=$@ if (( ! ${+img} )); then echo "no image(s)" >&2 fi local say="Let's rate some more images. From 1.0 to 5.0, decimal number scores with two digits, e.g. 2.9 and 3.1 is the format we use; where 1.0 = awful, 2.0 = bad, 3.0 = OK, 4.0 = good, and 5.0 = great. Don't motivate, just score by saying a number and nothing more." local model=${AI_MODEL} ollama run $model $say --keepalive=16m local res=result.txt for f in $@; do sleep 1 echo -n "$f: " | tee -a $res ollama run $model $say $f | tee -a $res done echo "done" img-ai-stop } img-ai-init () { local say=${1:-"Let's rate some photos and images."} local model=${2:-${AI_MODEL}} ollama run $model $say --keepalive=16m } alias say=img-ai-init img-ai-stop () { local model=${1:-${AI_MODEL}} ollama stop ${model} } img-ai () { local pic_path=$1 local model=${2:-${AI_MODEL}} local save=${3:-0} local abs_path=${pic_path:a} [[ ! -f $abs_path ]] && return if [[ $save = 0 ]]; then echo "[ ${abs_path} ]" ollama run ${model} "${abs_path}\n" --keepalive=0 2> /dev/null else local name=${abs_path:r} local file=${name}.txt /bin/touch $file echo "${name} [${abs_path}]" >> $file ollama run ${model} "${abs_path}\n" --keepalive=0 2> /dev/null | tee -a $file fi } # [llamafiles] # worked with: # llava-v1.5-7b-Q4_K.gguf # llava-v1.5-7b-mmproj-Q4_0.gguf # # this does not work for me: # - mistral outputs nonsensical HTML # - meta gibberish, repetitive patterns img-ai-dnc () { local f=$1 echo "now doing ... $f" ~/llm/llm \ --temp 0 \ --image $f \ --mmproj ~/llm/f16.gguf \ -e \ -p "### User: What do you see?\n### Assistant: " \ --no-display-prompt \ 2> /dev/null echo }