Slider to control LoRA strength

This commit is contained in:
cmdr2 2023-04-01 16:08:14 +05:30
parent 8ab445bb31
commit a03164f3bc
4 changed files with 15 additions and 14 deletions

View File

@ -95,7 +95,7 @@ if "%ERRORLEVEL%" EQU "0" (
set PYTHONNOUSERSITE=1 set PYTHONNOUSERSITE=1
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
call python -m pip install --upgrade sdkit==1.0.61 -q || ( call python -m pip install --upgrade sdkit==1.0.62 -q || (
echo "Error updating sdkit" echo "Error updating sdkit"
) )
) )
@ -106,7 +106,7 @@ if "%ERRORLEVEL%" EQU "0" (
set PYTHONNOUSERSITE=1 set PYTHONNOUSERSITE=1
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
call python -m pip install sdkit==1.0.61 || ( call python -m pip install sdkit==1.0.62 || (
echo "Error installing sdkit. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" echo "Error installing sdkit. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!"
pause pause
exit /b exit /b

View File

@ -103,7 +103,7 @@ if python ../scripts/check_modules.py sdkit sdkit.models ldm transformers numpy
export PYTHONNOUSERSITE=1 export PYTHONNOUSERSITE=1
export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages" export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages"
python -m pip install --upgrade sdkit==1.0.61 -q python -m pip install --upgrade sdkit==1.0.62 -q
fi fi
else else
echo "Installing sdkit: https://pypi.org/project/sdkit/" echo "Installing sdkit: https://pypi.org/project/sdkit/"
@ -111,7 +111,7 @@ else
export PYTHONNOUSERSITE=1 export PYTHONNOUSERSITE=1
export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages" export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages"
if python -m pip install sdkit==1.0.61 ; then if python -m pip install sdkit==1.0.62 ; then
echo "Installed." echo "Installed."
else else
fail "sdkit install failed" fail "sdkit install failed"

View File

@ -222,7 +222,7 @@
</td></tr> </td></tr>
<tr id="lora_alpha_container" class="pl-5"> <tr id="lora_alpha_container" class="pl-5">
<td><label for="lora_alpha_slider">LoRA strength:</label></td> <td><label for="lora_alpha_slider">LoRA strength:</label></td>
<td> <input id="lora_alpha_slider" name="lora_alpha_slider" class="editor-slider" value="100" type="range" min="0" max="100"> <input id="lora_alpha" name="lora_alpha" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td> <td> <input id="lora_alpha_slider" name="lora_alpha_slider" class="editor-slider" value="50" type="range" min="0" max="100"> <input id="lora_alpha" name="lora_alpha" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td>
</tr> </tr>
<tr class="pl-5"><td><label for="hypernetwork_model">Hypernetwork:</i></label></td><td> <tr class="pl-5"><td><label for="hypernetwork_model">Hypernetwork:</i></label></td><td>
<input id="hypernetwork_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" /> <input id="hypernetwork_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />

View File

@ -21,6 +21,7 @@ const taskConfigSetup = {
use_hypernetwork_model: 'Hypernetwork', use_hypernetwork_model: 'Hypernetwork',
hypernetwork_strength: { label: 'Hypernetwork Strength', visible: ({ reqBody }) => !!reqBody?.use_hypernetwork_model }, hypernetwork_strength: { label: 'Hypernetwork Strength', visible: ({ reqBody }) => !!reqBody?.use_hypernetwork_model },
use_lora_model: { label: 'Lora Model', visible: ({ reqBody }) => !!reqBody?.use_lora_model }, use_lora_model: { label: 'Lora Model', visible: ({ reqBody }) => !!reqBody?.use_lora_model },
lora_alpha: { label: 'Lora Strength', visible: ({ reqBody }) => !!reqBody?.use_lora_model },
preserve_init_image_color_profile: 'Preserve Color Profile', preserve_init_image_color_profile: 'Preserve Color Profile',
}, },
pluginTaskConfig: {}, pluginTaskConfig: {},
@ -1155,8 +1156,9 @@ function getCurrentUserRequest() {
newTask.reqBody.use_hypernetwork_model = hypernetworkModelField.value newTask.reqBody.use_hypernetwork_model = hypernetworkModelField.value
newTask.reqBody.hypernetwork_strength = parseFloat(hypernetworkStrengthField.value) newTask.reqBody.hypernetwork_strength = parseFloat(hypernetworkStrengthField.value)
} }
if (testDiffusers.checked) { if (testDiffusers.checked && loraModelField.value) {
newTask.reqBody.use_lora_model = loraModelField.value newTask.reqBody.use_lora_model = loraModelField.value
newTask.reqBody.lora_alpha = parseFloat(loraAlphaField.value)
} }
return newTask return newTask
} }
@ -1527,8 +1529,8 @@ function updateLoraAlpha() {
function updateLoraAlphaSlider() { function updateLoraAlphaSlider() {
if (loraAlphaField.value < 0) { if (loraAlphaField.value < 0) {
loraAlphaField.value = 0 loraAlphaField.value = 0
} else if (loraAlphaField.value > 0.99) { } else if (loraAlphaField.value > 1) {
loraAlphaField.value = 0.99 loraAlphaField.value = 1
} }
loraAlphaSlider.value = loraAlphaField.value * 100 loraAlphaSlider.value = loraAlphaField.value * 100
@ -1539,12 +1541,11 @@ loraAlphaSlider.addEventListener('input', updateLoraAlpha)
loraAlphaField.addEventListener('input', updateLoraAlphaSlider) loraAlphaField.addEventListener('input', updateLoraAlphaSlider)
updateLoraAlpha() updateLoraAlpha()
// function updateLoraAlphaContainer() { function updateLoraAlphaContainer() {
// document.querySelector("#lora_alpha_container").style.display = (loraModelField.value === "" ? 'none' : '') document.querySelector("#lora_alpha_container").style.display = (loraModelField.value === "" ? 'none' : '')
// } }
// loraModelField.addEventListener('change', updateLoraAlphaContainer) loraModelField.addEventListener('change', updateLoraAlphaContainer)
// updateLoraAlphaContainer() updateLoraAlphaContainer()
document.querySelector("#lora_alpha_container").style.display = 'none'
/********************* JPEG/WEBP Quality **********************/ /********************* JPEG/WEBP Quality **********************/
function updateOutputQuality() { function updateOutputQuality() {