mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-03-02 17:22:02 +01:00
Option to select Distilled Guidance Scale; Show warnings for Euler Ancestral sampler with Flux
This commit is contained in:
parent
90bc1456c9
commit
d283fb0776
@ -81,6 +81,7 @@ def generate_images(
|
||||
context: Context,
|
||||
callback=None,
|
||||
controlnet_filter=None,
|
||||
distilled_guidance_scale: float = 3.5,
|
||||
output_type="pil",
|
||||
**req,
|
||||
):
|
||||
|
@ -150,6 +150,7 @@ def generate_images(
|
||||
num_outputs: int = 1,
|
||||
num_inference_steps: int = 25,
|
||||
guidance_scale: float = 7.5,
|
||||
distilled_guidance_scale: float = 3.5,
|
||||
init_image=None,
|
||||
init_image_mask=None,
|
||||
control_image=None,
|
||||
@ -181,6 +182,7 @@ def generate_images(
|
||||
"steps": num_inference_steps,
|
||||
"seed": seed,
|
||||
"cfg_scale": guidance_scale,
|
||||
"distilled_cfg_scale": distilled_guidance_scale,
|
||||
"batch_size": num_outputs,
|
||||
"width": width,
|
||||
"height": height,
|
||||
|
@ -14,6 +14,7 @@ class GenerateImageRequest(BaseModel):
|
||||
num_outputs: int = 1
|
||||
num_inference_steps: int = 50
|
||||
guidance_scale: float = 7.5
|
||||
distilled_guidance_scale: float = 3.5
|
||||
|
||||
init_image: Any = None
|
||||
init_image_mask: Any = None
|
||||
|
@ -336,6 +336,7 @@
|
||||
</select>
|
||||
<a href="https://github.com/easydiffusion/easydiffusion/wiki/How-to-Use#samplers" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about samplers</span></i></a>
|
||||
</td></tr>
|
||||
<tr class="pl-5 warning-label displayNone" id="fluxSamplerWarning"><td></td><td>Please avoid 'Euler Ancestral' with Flux!</td></tr>
|
||||
<tr class="pl-5"><td><label>Image Size: </label></td><td id="image-size-options">
|
||||
<select id="width" name="width" value="512">
|
||||
<option value="128">128</option>
|
||||
@ -410,12 +411,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="small_image_warning" class="displayNone">Small image sizes can cause bad image quality</div>
|
||||
<div id="small_image_warning" class="displayNone warning-label">Small image sizes can cause bad image quality</div>
|
||||
</td></tr>
|
||||
<tr class="pl-5"><td><label for="num_inference_steps">Inference Steps:</label></td><td> <input id="num_inference_steps" name="num_inference_steps" type="number" min="1" step="1" style="width: 42pt" value="25" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"></td></tr>
|
||||
<tr class="pl-5"><td><label for="guidance_scale_slider">Guidance Scale:</label></td><td> <input id="guidance_scale_slider" name="guidance_scale_slider" class="editor-slider" value="75" type="range" min="11" max="500"> <input id="guidance_scale" name="guidance_scale" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"></td></tr>
|
||||
<tr class="pl-5 displayNone" id="guidanceWarning"><td></td><td id="guidanceWarningText"></td></tr>
|
||||
<tr class="pl-5 displayNone warning-label" id="guidanceWarning"><td></td><td id="guidanceWarningText"></td></tr>
|
||||
<tr id="prompt_strength_container" class="pl-5"><td><label for="prompt_strength_slider">Prompt Strength:</label></td><td> <input id="prompt_strength_slider" name="prompt_strength_slider" class="editor-slider" value="80" type="range" min="0" max="99"> <input id="prompt_strength" name="prompt_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"><br/></td></tr>
|
||||
<tr id="distilled_guidance_scale_container" class="pl-5 displayNone"><td><label for="distilled_guidance_scale_slider">Distilled Guidance:</label></td><td> <input id="distilled_guidance_scale_slider" name="distilled_guidance_scale_slider" class="editor-slider" value="35" type="range" min="11" max="500"> <input id="distilled_guidance_scale" name="distilled_guidance_scale" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"></td></tr>
|
||||
<tr id="lora_model_container" class="pl-5 gated-feature" data-feature-keys="backend_ed_diffusers backend_webui">
|
||||
<td>
|
||||
<label for="lora_model">LoRA:</label>
|
||||
|
@ -670,9 +670,9 @@ div.img-preview img {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#guidanceWarningText {
|
||||
.warning-label {
|
||||
font-size: smaller;
|
||||
color: var(--status-orange);
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
.display-settings {
|
||||
@ -1477,11 +1477,6 @@ div.top-right {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
#small_image_warning {
|
||||
font-size: smaller;
|
||||
color: var(--status-orange);
|
||||
}
|
||||
|
||||
button#save-system-settings-btn {
|
||||
padding: 4pt 8pt;
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ const taskConfigSetup = {
|
||||
sampler_name: "Sampler",
|
||||
num_inference_steps: "Inference Steps",
|
||||
guidance_scale: "Guidance Scale",
|
||||
distilled_guidance_scale: {
|
||||
label: "Distilled Guidance Scale",
|
||||
visible: ({ reqBody }) => reqBody?.distilled_guidance_scale,
|
||||
},
|
||||
use_stable_diffusion_model: "Model",
|
||||
clip_skip: {
|
||||
label: "Clip Skip",
|
||||
@ -76,6 +80,8 @@ let numOutputsParallelField = document.querySelector("#num_outputs_parallel")
|
||||
let numInferenceStepsField = document.querySelector("#num_inference_steps")
|
||||
let guidanceScaleSlider = document.querySelector("#guidance_scale_slider")
|
||||
let guidanceScaleField = document.querySelector("#guidance_scale")
|
||||
let distilledGuidanceScaleSlider = document.querySelector("#distilled_guidance_scale_slider")
|
||||
let distilledGuidanceScaleField = document.querySelector("#distilled_guidance_scale")
|
||||
let outputQualitySlider = document.querySelector("#output_quality_slider")
|
||||
let outputQualityField = document.querySelector("#output_quality")
|
||||
let outputQualityRow = document.querySelector("#output_quality_row")
|
||||
@ -1051,6 +1057,9 @@ function makeImage() {
|
||||
if (guidanceScaleField.value == "") {
|
||||
guidanceScaleField.value = guidanceScaleSlider.value / 10
|
||||
}
|
||||
if (distilledGuidanceScaleField.value == "") {
|
||||
distilledGuidanceScaleField.value = distilledGuidanceScaleSlider.value / 10
|
||||
}
|
||||
if (hypernetworkStrengthField.value == "") {
|
||||
hypernetworkStrengthField.value = hypernetworkStrengthSlider.value / 100
|
||||
}
|
||||
@ -1419,6 +1428,9 @@ function getCurrentUserRequest() {
|
||||
newTask.reqBody.control_filter_to_apply = controlImageFilterField.value
|
||||
}
|
||||
}
|
||||
if (stableDiffusionModelField.value.toLowerCase().includes("flux")) {
|
||||
newTask.reqBody.distilled_guidance_scale = parseFloat(distilledGuidanceScaleField.value)
|
||||
}
|
||||
|
||||
return newTask
|
||||
}
|
||||
@ -1866,14 +1878,14 @@ function checkGuidanceValue() {
|
||||
let guidanceWarningText = document.querySelector("#guidanceWarningText")
|
||||
if (sdModelField.value.toLowerCase().includes("flux")) {
|
||||
if (guidance > 1.5) {
|
||||
guidanceWarningText.innerText = "Flux recommends a guidance scale of 1"
|
||||
guidanceWarningText.innerText = "Flux recommends a 'Guidance Scale' of 1"
|
||||
guidanceWarning.classList.remove("displayNone")
|
||||
} else {
|
||||
guidanceWarning.classList.add("displayNone")
|
||||
}
|
||||
} else {
|
||||
if (guidance < 2) {
|
||||
guidanceWarningText.innerText = "A higher Guidance Scale is recommended!"
|
||||
guidanceWarningText.innerText = "A higher 'Guidance Scale' is recommended!"
|
||||
guidanceWarning.classList.remove("displayNone")
|
||||
} else {
|
||||
guidanceWarning.classList.add("displayNone")
|
||||
@ -1884,6 +1896,37 @@ sdModelField.addEventListener("change", checkGuidanceValue)
|
||||
guidanceScaleField.addEventListener("change", checkGuidanceValue)
|
||||
guidanceScaleSlider.addEventListener("change", checkGuidanceValue)
|
||||
|
||||
function checkGuidanceScaleVisibility() {
|
||||
let guidanceScaleContainer = document.querySelector("#distilled_guidance_scale_container")
|
||||
if (sdModelField.value.toLowerCase().includes("flux")) {
|
||||
guidanceScaleContainer.classList.remove("displayNone")
|
||||
} else {
|
||||
guidanceScaleContainer.classList.add("displayNone")
|
||||
}
|
||||
}
|
||||
sdModelField.addEventListener("change", checkGuidanceScaleVisibility)
|
||||
|
||||
function checkFluxSampler() {
|
||||
let samplerWarning = document.querySelector("#fluxSamplerWarning")
|
||||
if (sdModelField.value.toLowerCase().includes("flux")) {
|
||||
if (samplerField.value == "euler_a") {
|
||||
samplerWarning.classList.remove("displayNone")
|
||||
} else {
|
||||
samplerWarning.classList.add("displayNone")
|
||||
}
|
||||
} else {
|
||||
samplerWarning.classList.add("displayNone")
|
||||
}
|
||||
}
|
||||
sdModelField.addEventListener("change", checkFluxSampler)
|
||||
samplerField.addEventListener("change", checkFluxSampler)
|
||||
|
||||
document.addEventListener("refreshModels", function() {
|
||||
checkGuidanceValue()
|
||||
checkGuidanceScaleVisibility()
|
||||
checkFluxSampler()
|
||||
})
|
||||
|
||||
// function onControlImageFilterChange() {
|
||||
// let filterId = controlImageFilterField.value
|
||||
// if (filterId.includes("openpose")) {
|
||||
@ -2012,6 +2055,27 @@ guidanceScaleSlider.addEventListener("input", updateGuidanceScale)
|
||||
guidanceScaleField.addEventListener("input", updateGuidanceScaleSlider)
|
||||
updateGuidanceScale()
|
||||
|
||||
/********************* Distilled Guidance **************************/
|
||||
function updateDistilledGuidanceScale() {
|
||||
distilledGuidanceScaleField.value = distilledGuidanceScaleSlider.value / 10
|
||||
distilledGuidanceScaleField.dispatchEvent(new Event("change"))
|
||||
}
|
||||
|
||||
function updateDistilledGuidanceScaleSlider() {
|
||||
if (distilledGuidanceScaleField.value < 0) {
|
||||
distilledGuidanceScaleField.value = 0
|
||||
} else if (distilledGuidanceScaleField.value > 50) {
|
||||
distilledGuidanceScaleField.value = 50
|
||||
}
|
||||
|
||||
distilledGuidanceScaleSlider.value = distilledGuidanceScaleField.value * 10
|
||||
distilledGuidanceScaleSlider.dispatchEvent(new Event("change"))
|
||||
}
|
||||
|
||||
distilledGuidanceScaleSlider.addEventListener("input", updateDistilledGuidanceScale)
|
||||
distilledGuidanceScaleField.addEventListener("input", updateDistilledGuidanceScaleSlider)
|
||||
updateDistilledGuidanceScale()
|
||||
|
||||
/********************* Prompt Strength *******************/
|
||||
function updatePromptStrength() {
|
||||
promptStrengthField.value = promptStrengthSlider.value / 100
|
||||
|
Loading…
Reference in New Issue
Block a user