From cca62a4176805515443f1e0dbe3814feca4640cf Mon Sep 17 00:00:00 2001 From: kyxsune Date: Sat, 14 Jan 2023 02:02:54 -0500 Subject: [PATCH 1/3] Added all the info --- .gitignore | 1 + index.html | 48 ++++++++++++++++++++++++++++-------------------- index.js | 49 +++++++++++++++++++++++++++++++++++++++++++------ start_server.sh | 2 +- 4 files changed, 73 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index d8f9212..da0ed04 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ server/python_server/init_images/* node_modules/ server/python_server/prompt_shortcut.json experimental/ +start_server.sh diff --git a/index.html b/index.html index 43accde..95c5269 100644 --- a/index.html +++ b/index.html @@ -504,16 +504,6 @@ 512 -
- - Hi Res Width: - 512 - - - Hi Res Height: - 512 - -
CFG Scale: @@ -523,12 +513,7 @@ Denoising Strength: 0.7 - - High Res Denoising Strength: - 0.7 - - - + Mask Blur: @@ -543,8 +528,33 @@ latent nothing - Inpaint at full resolution - Hi Res Fix +
+ Inpaint at full resolution + Hi Res Fix +
+ Inpaint Padding: 0 @@ -581,8 +591,6 @@ DPM++ 2S a Karras DPM++ 2M Karras DPM++ SDE Karras - - diff --git a/index.js b/index.js index 9da4cf4..7dc8fd5 100644 --- a/index.js +++ b/index.js @@ -352,8 +352,6 @@ function promptShortcutExample(){ document.getElementById('taPromptShortcut').value = JSONInPrettyFormat } - - function autoFillInSettings(metadata_json){ try{ @@ -862,6 +860,10 @@ document.querySelector('#hrWidth').addEventListener('input', evt => { hWidth = sliderToResolution(evt.target.value) document.querySelector('#hWidth').textContent = hWidth }) +document.querySelector('#hrScale').addEventListener('input', evt => { + hScale = sliderToResolution(evt.target.value) + document.querySelector('#hScale').textContent = hScale +}) document.querySelector('#slInpaintPadding').addEventListener('input', evt => { padding = evt.target.value * 4 document.querySelector('#lInpaintPadding').textContent = padding @@ -1366,8 +1368,6 @@ function updateMetadata (new_metadata) { async function getSettings(){ let payload = {} try{ - - numberOfImages = document.querySelector('#tiNumberOfImages').value numberOfSteps = document.querySelector('#tiNumberOfSteps').value const prompt = html_manip.getPrompt() @@ -1376,6 +1376,7 @@ async function getSettings(){ // console.log("prompt:",prompt) // console.log("negative_prompt:",negative_prompt) const model_index = document.querySelector('#mModelsMenu').selectedIndex + const upscaler = document.querySelector('#hrModelsMenu').value const cfg_scale = document.querySelector('#slCfgScale').value // const model_index = document.querySelector("#") const seed = document.querySelector('#tiSeed').value @@ -1401,6 +1402,8 @@ async function getSettings(){ const height = html_manip.getHeight() const hWidth = html_manip.getSliderSdValue('hrWidth',64) const hHeight = html_manip.getSliderSdValue('hrHeight',64) + const hSteps = html_manip.getSliderSdValue('hrNumberOfSteps',1) + const hScale = html_manip.getSliderSdValue('hrScale',1) console.log("Check") const uniqueDocumentId = await getUniqueDocumentId() @@ -1441,13 +1444,14 @@ async function getSettings(){ payload['denoising_strength'] = denoising_strength payload['init_image_name'] = g_init_image_name - - } if(hi_res_fix){ payload['enable_hr'] = hi_res_fix payload['firstphase_width'] = hWidth payload['firstphase_height'] = hHeight + payload['hr_scale'] = hScale // Scale + payload['hr_upscaler'] = upscaler // Upscaler + payload['hr_second_pass_steps'] = hSteps // Number of Steps }else{ //fix hi res bug: if we include firstphase_width or firstphase_height in the payload, // sd api will use them instead of using width and height variables, even when enable_hr is set to "false" @@ -2532,4 +2536,37 @@ document }) +// Hi res fix stuff +var hr_models = [ + "Latent", + "Latent (antialiased)", + "Latent (bicubic)", + "Latent (bicubic antialiased)", + "Latent (nearest)", + "Latent (nearest-exact)", + "Lanczos", + "Nearest", + "ESRGAN", + "RealESRGAN", + "LDSR", + "SwinIR" +] + +for (let model of hr_models) { + // console.log(model.title) + const menu_item_element = document.createElement('sp-menu-item') + menu_item_element.className = "hrModelsMenuItem" + menu_item_element.innerHTML = model + document.getElementById('hrModelsMenu').appendChild(menu_item_element) +} + +var chHiResFixs = document.getElementById("chHiResFixs"); +var div = document.getElementById("HiResDiv"); +chHiResFixs.addEventListener("change", function() { + if (chHiResFixs.checked) { + div.style.display = "block"; + } else { + div.style.display = "none"; + } +}); diff --git a/start_server.sh b/start_server.sh index 416f0a0..db8fa7b 100755 --- a/start_server.sh +++ b/start_server.sh @@ -1,7 +1,7 @@ #!/bin/bash git pull # Set the desired remote host where the "<>" is -export SD_URL=http://127.0.0.1:7860 +export SD_URL=http://level:7860 # Check if the desired environment exists if [ ! -d "server_env" ]; then From 39741547324d4e951e4dbec536bc3d1ba5748fbf Mon Sep 17 00:00:00 2001 From: Kyxsune Date: Sat, 14 Jan 2023 02:03:23 -0500 Subject: [PATCH 2/3] Update start_server.sh --- start_server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start_server.sh b/start_server.sh index db8fa7b..416f0a0 100755 --- a/start_server.sh +++ b/start_server.sh @@ -1,7 +1,7 @@ #!/bin/bash git pull # Set the desired remote host where the "<>" is -export SD_URL=http://level:7860 +export SD_URL=http://127.0.0.1:7860 # Check if the desired environment exists if [ ! -d "server_env" ]; then From fbfcecec5e6d4c0af16bc71e35a28cc8ed12d421 Mon Sep 17 00:00:00 2001 From: kyxsune Date: Sat, 14 Jan 2023 12:48:43 -0500 Subject: [PATCH 3/3] Changed Behaviour to sync with other aspects --- .gitignore | 1 + html_manip.js | 17 ++++++++++++++++- index.html | 6 ++---- index.js | 26 ++++++++++++++++---------- selection.js | 2 +- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index da0ed04..d8cd914 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ node_modules/ server/python_server/prompt_shortcut.json experimental/ start_server.sh +start_server.sh diff --git a/html_manip.js b/html_manip.js index 745e656..c52b8dc 100644 --- a/html_manip.js +++ b/html_manip.js @@ -66,6 +66,19 @@ function autoFillInHeight(height_value){ //update the label document.getElementById('lHeight').innerHTML = `${height_value}` } + +function autoFillInHRHeight(height_value){ + document.getElementById('hrHeight').value = `${height_value / 64}` + //update the label + document.getElementById('hHeight').innerHTML = `${height_value}` +} + +function autoFillInHRWidth(height_value){ + document.getElementById('hrWidth').value = `${height_value / 64}` + //update the label + document.getElementById('hWidth').innerHTML = `${height_value}` +} + ////// End Height////////// @@ -398,5 +411,7 @@ module.exports = { defaultSettings, autoFillDefaultSettings, getMaskBlur, - getUseSharpMask + getUseSharpMask, + autoFillInHRHeight, + autoFillInHRWidth } \ No newline at end of file diff --git a/index.html b/index.html index 95c5269..a601c71 100644 --- a/index.html +++ b/index.html @@ -541,19 +541,17 @@ Hr Steps: - Hi Res Width: + Hi Res Output Width: 512 - Hi Res Height: + Hi Res Output Height: 512 High Res Denoising Strength: 0.7 - Hr Scale: Inpaint Padding: diff --git a/index.js b/index.js index 7dc8fd5..9a80005 100644 --- a/index.js +++ b/index.js @@ -27,11 +27,13 @@ const eventHandler = async (event, descriptor) => { const isSelectionActive = await psapi.checkIfSelectionAreaIsActive() if (isSelectionActive){ - const [final_width,final_height] = await selection.selectionToFinalWidthHeight() + const [final_width,final_height,initial_width,initial_height] = await selection.selectionToFinalWidthHeight() console.log("(final_width,final_height):",final_width,final_height) console.log(event, descriptor) html_manip.autoFillInWidth(final_width) html_manip.autoFillInHeight(final_height) + html_manip.autoFillInHRWidth(initial_width) + html_manip.autoFillInHRHeight(initial_height) // if selection has changed : change the color and text generate btn "Generate" color "red" const new_selection = await psapi.getSelectionInfoExe() if(await hasSelectionChanged(new_selection,g_selection)){ @@ -567,11 +569,13 @@ document.addEventListener("mouseenter",async (event)=>{ const new_selection = await psapi.getSelectionInfoExe() if(await hasSelectionChanged(new_selection,g_selection)){ - const [final_width,final_height] = await selection.selectionToFinalWidthHeight() + const [final_width,final_height,initial_width,initial_height] = await selection.selectionToFinalWidthHeight() console.log("(final_width,final_height):",final_width,final_height) html_manip.autoFillInWidth(final_width) html_manip.autoFillInHeight(final_height) + html_manip.autoFillInHRWidth(initial_width) + html_manip.autoFillInHRHeight(initial_height) sessionStartHtml(false)//generate ,red color }else{ @@ -860,10 +864,10 @@ document.querySelector('#hrWidth').addEventListener('input', evt => { hWidth = sliderToResolution(evt.target.value) document.querySelector('#hWidth').textContent = hWidth }) -document.querySelector('#hrScale').addEventListener('input', evt => { - hScale = sliderToResolution(evt.target.value) - document.querySelector('#hScale').textContent = hScale -}) +//document.querySelector('#hrScale').addEventListener('input', evt => { +// hScale = sliderToResolution(evt.target.value) +// document.querySelector('#hScale').textContent = hScale +//}) document.querySelector('#slInpaintPadding').addEventListener('input', evt => { padding = evt.target.value * 4 document.querySelector('#lInpaintPadding').textContent = padding @@ -1403,7 +1407,7 @@ async function getSettings(){ const hWidth = html_manip.getSliderSdValue('hrWidth',64) const hHeight = html_manip.getSliderSdValue('hrHeight',64) const hSteps = html_manip.getSliderSdValue('hrNumberOfSteps',1) - const hScale = html_manip.getSliderSdValue('hrScale',1) + //const hScale = html_manip.getSliderSdValue('hrScale',1) console.log("Check") const uniqueDocumentId = await getUniqueDocumentId() @@ -1447,9 +1451,11 @@ async function getSettings(){ } if(hi_res_fix){ payload['enable_hr'] = hi_res_fix - payload['firstphase_width'] = hWidth - payload['firstphase_height'] = hHeight - payload['hr_scale'] = hScale // Scale + payload['firstphase_width'] = width + payload['firstphase_height'] = height + payload['hr_resize_x'] = hWidth + payload['hr_resize_y'] = hHeight + // payload['hr_scale'] = hScale // Scale payload['hr_upscaler'] = upscaler // Upscaler payload['hr_second_pass_steps'] = hSteps // Number of Steps }else{ diff --git a/selection.js b/selection.js index adbe743..d999ace 100644 --- a/selection.js +++ b/selection.js @@ -31,7 +31,7 @@ async function selectionToFinalWidthHeight(){ const selectionInfo = await getSelectionInfoExe() const [finalWidth,finalHeight] = finalWidthHeight(selectionInfo.width,selectionInfo.height,512,512) - return [parseInt(finalWidth),parseInt(finalHeight)] + return [parseInt(finalWidth),parseInt(finalHeight),selectionInfo.width,selectionInfo.height] }catch(e){ console.warn("you need a rectangular selection",e) }