From 40c27b91c6f4f7ee9f7a49818ccfb79c8feb20c9 Mon Sep 17 00:00:00 2001 From: themanyone Date: Mon, 2 Feb 2026 20:40:59 -0900 Subject: [PATCH] set cfg_scale in the guidance parameters --- examples/server/main.cpp | 6 +++++ ggml | 2 +- sd_completions.sh | 49 ++++++++++++++++++++++++++++++++++++++++ up | 32 ++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 sd_completions.sh create mode 100755 up diff --git a/examples/server/main.cpp b/examples/server/main.cpp index def499755..6e4be29c9 100644 --- a/examples/server/main.cpp +++ b/examples/server/main.cpp @@ -399,6 +399,9 @@ int main(int argc, const char** argv) { gen_params.height = height; gen_params.batch_count = n; + // Correctly set cfg_scale in the guidance parameters + gen_params.sample_params.guidance.txt_cfg = j.value("cfg_scale", gen_params.sample_params.guidance.txt_cfg); + if (!sd_cpp_extra_args_str.empty() && !gen_params.from_json_str(sd_cpp_extra_args_str)) { res.status = 400; res.set_content(R"({"error":"invalid sd_cpp_extra_args"})", "application/json"); @@ -810,6 +813,9 @@ int main(int argc, const char** argv) { gen_params.sample_params.sample_steps = steps; gen_params.batch_count = batch_size; + // set cfg_scale in the guidance parameters + gen_params.sample_params.guidance.txt_cfg = cfg_scale; + if (clip_skip > 0) { gen_params.clip_skip = clip_skip; } diff --git a/ggml b/ggml index a8db410a2..8891ab6fc 160000 --- a/ggml +++ b/ggml @@ -1 +1 @@ -Subproject commit a8db410a252c8c8f2d120c6f2e7133ebe032f35d +Subproject commit 8891ab6fc742ac1198736d3da3b73c730e42af84 diff --git a/sd_completions.sh b/sd_completions.sh new file mode 100644 index 000000000..23defb377 --- /dev/null +++ b/sd_completions.sh @@ -0,0 +1,49 @@ +_sd_completions() { + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="-diffusion -cli -o --output -style --preview-path --preview-interval --output-begin-idx -negative --canny --convert-name -v --verbose --color --taesd-preview-only --preview --preview-noisy --mode --preview -h --help -m --model --clip -l --clip -g --clip -vision --t --llm -image -small --llm --qwen --llm --qwen --llm --diffusion-model --high-noise-diffusion-model --vae --taesd --tae --taesd --control-net --embd-dir --lora-model-dir --tensor-type-rules --photo-maker --upscale-model -t --threads --chroma-t -mask-pad --vae-tile-overlap --flow-shift --vae-tiling --force-sdxl-vae-conv-scale --offload-to-cpu --mmap -map --control-net-cpu --clip-on-cpu --vae-on-cpu --diffusion-fa --diffusion-conv-direct --vae-conv-direct --circular --circularx -axis --circulary -axis --chroma-disable-dit-mask --qwen-image-zero-cond-t --chroma-enable-t -mask --type --rng -webui --sampler-rng --rng --prediction --lora-apply-mode --vae-tile-size --vae-relative-tile-size --vae-tile-size -p --prompt -n --negative-prompt -i --init-img --end-img --mask --control-image --control-video --pm-id-images-dir --pm-id-embed-path --height --width --steps --high-noise-steps --clip-skip -b --batch-count --video-frames --fps --timestep-shift --upscale-repeats --upscale-tile-size --cfg-scale --img-cfg-scale -pix --cfg-scale --guidance --slg-scale --skip-layer-start --skip-layer-end --eta --high-noise-cfg-scale --high-noise-img-cfg-scale -pix --cfg-scale --high-noise-guidance --high-noise-slg-scale --high-noise-skip-layer-start --high-noise-skip-layer-end --high-noise-eta --strength --pm-style-strength --control-strength --moe-boundary --high-noise-steps --vace-strength --increase-ref-index --disable-auto-resize-ref-image -s --seed --sampling-method --high-noise-sampling-method --scheduler --sigmas -separated --skip-layers --high-noise-skip-layers -r --ref-image --cache-mode -dit -level --cache-option -separated -dit --cache-preset -dit --scm-mask -dit -separated --scm-policy" + + case "$prev" in + --diffusion-model) + COMPREPLY=( $(compgen -f -X '!*.gguf' -- "$cur") $(compgen -d -- "$cur") ) + return 0 + ;; + -m) + COMPREPLY=( $(compgen -f -X '!*.safetensors' -- "$cur") $(compgen -d -- "$cur") ) + return 0 + ;; + *) + COMPREPLY=( $(compgen -W "${opts}" -- "$cur") ) + return 0 + ;; + esac +} +_sd_server_comps() { + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="-diffusion -server -l --listen-ip --serve-html-path --listen-port -v --verbose --color -h --help -m --model --clip -l --clip -g --clip -vision --t --llm -image -small --llm --qwen --llm --qwen --llm --diffusion-model --high-noise-diffusion-model --vae --taesd --tae --taesd --control-net --embd-dir --lora-model-dir --tensor-type-rules --photo-maker --upscale-model -t --threads --chroma-t -mask-pad --vae-tile-overlap --flow-shift --vae-tiling --force-sdxl-vae-conv-scale --offload-to-cpu --mmap -map --control-net-cpu --clip-on-cpu --vae-on-cpu --diffusion-fa --diffusion-conv-direct --vae-conv-direct --circular --circularx -axis --circulary -axis --chroma-disable-dit-mask --qwen-image-zero-cond-t --chroma-enable-t -mask --type --rng -webui --sampler-rng --rng --prediction --lora-apply-mode --vae-tile-size --vae-relative-tile-size --vae-tile-size -p --prompt -n --negative-prompt -i --init-img --end-img --mask --control-image --control-video --pm-id-images-dir --pm-id-embed-path --height --width --steps --high-noise-steps --clip-skip -b --batch-count --video-frames --fps --timestep-shift --upscale-repeats --upscale-tile-size --cfg-scale --img-cfg-scale -pix --cfg-scale --guidance --slg-scale --skip-layer-start --skip-layer-end --eta --high-noise-cfg-scale --high-noise-img-cfg-scale -pix --cfg-scale --high-noise-guidance --high-noise-slg-scale --high-noise-skip-layer-start --high-noise-skip-layer-end --high-noise-eta --strength --pm-style-strength --control-strength --moe-boundary --high-noise-steps --vace-strength --increase-ref-index --disable-auto-resize-ref-image -s --seed --sampling-method --high-noise-sampling-method --scheduler --sigmas -separated --skip-layers --high-noise-skip-layers -r --ref-image --cache-mode -dit -level --cache-option -separated -dit --cache-preset -dit --scm-mask -dit -separated --scm-policy" + + case "$prev" in + --diffusion-model) + COMPREPLY=( $(compgen -f -X '!*.gguf' -- "$cur") $(compgen -d -- "$cur") ) + return 0 + ;; + -m) + COMPREPLY=( $(compgen -f -X '!*.safetensors' -- "$cur") $(compgen -d -- "$cur") ) + return 0 + ;; + *) + COMPREPLY=( $(compgen -W "${opts}" -- "$cur") ) + return 0 + ;; + esac +} + +complete -F _sd_completions sd-cli +complete -F _sd_server_comps sd-server diff --git a/up b/up new file mode 100755 index 000000000..58ea70cab --- /dev/null +++ b/up @@ -0,0 +1,32 @@ +#!/bin/bash +#echo export CUDAHOSTCXX=g++-13 #>> .bashrc +#!/bin/bash + +# 1. Store the current commit hash +OLD_COMMIT=$(git rev-parse HEAD) + +echo "Current commit: $OLD_COMMIT" + +# 2. Perform the git pull +# Using '|| exit' ensures the script stops if the pull command itself fails +git pull || { echo "git pull failed"; exit 1; } + +# 3. Store the new commit hash +NEW_COMMIT=$(git rev-parse HEAD) + +echo "New commit: $NEW_COMMIT" + +# 4. Compare the hashes +if [ "$OLD_COMMIT" != "$NEW_COMMIT" ]; then + echo "Repository updated with new commits." + # --- PLACE YOUR COMMANDS HERE --- + +cmake -B build -DSD_CUDA=ON -DCMAKE_CXX_FLAGS="-w" +cmake --build . --config Release +cmake --install build --prefix $HOME/.local + +#cmake -B build -DGGML_BLAS=1 -DGGML_BLAS_VENDOR=OpenBLAS -j8 + +else + echo "Repository was already up-to-date." +fi