mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-05 03:32:37 +00:00
extra networks UI
rework of hypernets: rather than via settings, hypernets are added directly to prompt as <hypernet:name:weight>
This commit is contained in:
60
javascript/extraNetworks.js
Normal file
60
javascript/extraNetworks.js
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
function setupExtraNetworksForTab(tabname){
|
||||
gradioApp().querySelector('#'+tabname+'_extra_tabs').classList.add('extra-networks')
|
||||
|
||||
gradioApp().querySelector('#'+tabname+'_extra_tabs > div').appendChild(gradioApp().getElementById(tabname+'_extra_refresh'))
|
||||
gradioApp().querySelector('#'+tabname+'_extra_tabs > div').appendChild(gradioApp().getElementById(tabname+'_extra_close'))
|
||||
}
|
||||
|
||||
var activePromptTextarea = null;
|
||||
var activePositivePromptTextarea = null;
|
||||
|
||||
function setupExtraNetworks(){
|
||||
setupExtraNetworksForTab('txt2img')
|
||||
setupExtraNetworksForTab('img2img')
|
||||
|
||||
function registerPrompt(id, isNegative){
|
||||
var textarea = gradioApp().querySelector("#" + id + " > label > textarea");
|
||||
|
||||
if (activePromptTextarea == null){
|
||||
activePromptTextarea = textarea
|
||||
}
|
||||
if (activePositivePromptTextarea == null && ! isNegative){
|
||||
activePositivePromptTextarea = textarea
|
||||
}
|
||||
|
||||
textarea.addEventListener("focus", function(){
|
||||
activePromptTextarea = textarea;
|
||||
if(! isNegative) activePositivePromptTextarea = textarea;
|
||||
});
|
||||
}
|
||||
|
||||
registerPrompt('txt2img_prompt')
|
||||
registerPrompt('txt2img_neg_prompt', true)
|
||||
registerPrompt('img2img_prompt')
|
||||
registerPrompt('img2img_neg_prompt', true)
|
||||
}
|
||||
|
||||
onUiLoaded(setupExtraNetworks)
|
||||
|
||||
function cardClicked(textToAdd, allowNegativePrompt){
|
||||
textarea = allowNegativePrompt ? activePromptTextarea : activePositivePromptTextarea
|
||||
|
||||
textarea.value = textarea.value + " " + textToAdd
|
||||
updateInput(textarea)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
function saveCardPreview(event, tabname, filename){
|
||||
textarea = gradioApp().querySelector("#" + tabname + '_preview_filename > label > textarea')
|
||||
button = gradioApp().getElementById(tabname + '_save_preview')
|
||||
|
||||
textarea.value = filename
|
||||
updateInput(textarea)
|
||||
|
||||
button.click()
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
}
|
@@ -21,6 +21,8 @@ titles = {
|
||||
"\U0001F5D1": "Clear prompt",
|
||||
"\u{1f4cb}": "Apply selected styles to current prompt",
|
||||
"\u{1f4d2}": "Paste available values into the field",
|
||||
"\u{1f3b4}": "Show extra networks",
|
||||
|
||||
|
||||
"Inpaint a part of image": "Draw a mask over an image, and the script will regenerate the masked area with content according to prompt",
|
||||
"SD upscale": "Upscale image normally, split result into tiles, improve each tile using img2img, merge whole image back",
|
||||
|
@@ -196,8 +196,6 @@ function confirm_clear_prompt(prompt, negative_prompt) {
|
||||
return [prompt, negative_prompt]
|
||||
}
|
||||
|
||||
|
||||
|
||||
opts = {}
|
||||
onUiUpdate(function(){
|
||||
if(Object.keys(opts).length != 0) return;
|
||||
@@ -239,11 +237,14 @@ onUiUpdate(function(){
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
prompt.parentElement.insertBefore(counter, prompt)
|
||||
counter.classList.add("token-counter")
|
||||
prompt.parentElement.style.position = "relative"
|
||||
|
||||
textarea.addEventListener("input", () => update_token_counter(id_button));
|
||||
textarea.addEventListener("input", function(){
|
||||
update_token_counter(id_button);
|
||||
});
|
||||
}
|
||||
|
||||
registerTextarea('txt2img_prompt', 'txt2img_token_counter', 'txt2img_token_button')
|
||||
@@ -261,10 +262,8 @@ onUiUpdate(function(){
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
onOptionsChanged(function(){
|
||||
elem = gradioApp().getElementById('sd_checkpoint_hash')
|
||||
sd_checkpoint_hash = opts.sd_checkpoint_hash || ""
|
||||
|
Reference in New Issue
Block a user