aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'javascript')
-rw-r--r--javascript/extensions.js20
-rw-r--r--javascript/extraNetworks.js42
-rw-r--r--javascript/hints.js10
-rw-r--r--javascript/ui.js43
4 files changed, 97 insertions, 18 deletions
diff --git a/javascript/extensions.js b/javascript/extensions.js
index ac6e35b9..c593cd2e 100644
--- a/javascript/extensions.js
+++ b/javascript/extensions.js
@@ -1,7 +1,8 @@
function extensions_apply(_, _){
- disable = []
- update = []
+ var disable = []
+ var update = []
+
gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){
if(x.name.startsWith("enable_") && ! x.checked)
disable.push(x.name.substr(7))
@@ -16,11 +17,24 @@ function extensions_apply(_, _){
}
function extensions_check(){
+ var disable = []
+
+ gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){
+ if(x.name.startsWith("enable_") && ! x.checked)
+ disable.push(x.name.substr(7))
+ })
+
gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x){
x.innerHTML = "Loading..."
})
- return []
+
+ var id = randomId()
+ requestProgress(id, gradioApp().getElementById('extensions_installed_top'), null, function(){
+
+ })
+
+ return [id, JSON.stringify(disable)]
}
function install_extension_from_index(button, url){
diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js
index c5a9adb3..17bf2000 100644
--- a/javascript/extraNetworks.js
+++ b/javascript/extraNetworks.js
@@ -16,7 +16,7 @@ function setupExtraNetworksForTab(tabname){
searchTerm = search.value.toLowerCase()
gradioApp().querySelectorAll('#'+tabname+'_extra_tabs div.card').forEach(function(elem){
- text = elem.querySelector('.name').textContent.toLowerCase()
+ text = elem.querySelector('.name').textContent.toLowerCase() + " " + elem.querySelector('.search_term').textContent.toLowerCase()
elem.style.display = text.indexOf(searchTerm) == -1 ? "none" : ""
})
});
@@ -48,10 +48,39 @@ function setupExtraNetworks(){
onUiLoaded(setupExtraNetworks)
+var re_extranet = /<([^:]+:[^:]+):[\d\.]+>/;
+var re_extranet_g = /\s+<([^:]+:[^:]+):[\d\.]+>/g;
+
+function tryToRemoveExtraNetworkFromPrompt(textarea, text){
+ var m = text.match(re_extranet)
+ if(! m) return false
+
+ var partToSearch = m[1]
+ var replaced = false
+ var newTextareaText = textarea.value.replaceAll(re_extranet_g, function(found, index){
+ m = found.match(re_extranet);
+ if(m[1] == partToSearch){
+ replaced = true;
+ return ""
+ }
+ return found;
+ })
+
+ if(replaced){
+ textarea.value = newTextareaText
+ return true;
+ }
+
+ return false
+}
+
function cardClicked(tabname, textToAdd, allowNegativePrompt){
var textarea = allowNegativePrompt ? activePromptTextarea[tabname] : gradioApp().querySelector("#" + tabname + "_prompt > label > textarea")
- textarea.value = textarea.value + " " + textToAdd
+ if(! tryToRemoveExtraNetworkFromPrompt(textarea, textToAdd)){
+ textarea.value = textarea.value + " " + textToAdd
+ }
+
updateInput(textarea)
}
@@ -67,3 +96,12 @@ function saveCardPreview(event, tabname, filename){
event.stopPropagation()
event.preventDefault()
}
+
+function extraNetworksSearchButton(tabs_id, event){
+ searchTextarea = gradioApp().querySelector("#" + tabs_id + ' > div > textarea')
+ button = event.target
+ text = button.classList.contains("search-all") ? "" : button.textContent.trim()
+
+ searchTextarea.value = text
+ updateInput(searchTextarea)
+} \ No newline at end of file
diff --git a/javascript/hints.js b/javascript/hints.js
index 7b60b25e..f1199009 100644
--- a/javascript/hints.js
+++ b/javascript/hints.js
@@ -8,8 +8,8 @@ titles = {
"DDIM": "Denoising Diffusion Implicit Models - best at inpainting",
"DPM adaptive": "Ignores step count - uses a number of steps determined by the CFG and resolution",
- "Batch count": "How many batches of images to create",
- "Batch size": "How many image to create in a single batch",
+ "Batch count": "How many batches of images to create (has no impact on generation performance or VRAM usage)",
+ "Batch size": "How many image to create in a single batch (increases generation performance at cost of higher VRAM usage)",
"CFG Scale": "Classifier Free Guidance Scale - how strongly the image should conform to prompt - lower values produce more creative results",
"Seed": "A value that determines the output of random number generator - if you create an image with same parameters and seed as another image, you'll get the same result",
"\u{1f3b2}\ufe0f": "Set seed to -1, which will cause a new random number to be used every time",
@@ -17,7 +17,7 @@ titles = {
"\u2199\ufe0f": "Read generation parameters from prompt or last generation if prompt is empty into user interface.",
"\u{1f4c2}": "Open images output directory",
"\u{1f4be}": "Save style",
- "\U0001F5D1": "Clear prompt",
+ "\u{1f5d1}": "Clear prompt",
"\u{1f4cb}": "Apply selected styles to current prompt",
"\u{1f4d2}": "Paste available values into the field",
"\u{1f3b4}": "Show extra networks",
@@ -66,8 +66,8 @@ titles = {
"Interrogate": "Reconstruct prompt from existing image and put it into the prompt field.",
- "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_no_styles], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [model_name], [prompt_words], [date], [datetime], [datetime<Format>], [datetime<Format><Time Zone>], [job_timestamp]; leave empty for default.",
- "Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg], [prompt], [prompt_no_styles], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [model_name], [prompt_words], [date], [datetime], [datetime<Format>], [datetime<Format><Time Zone>], [job_timestamp]; leave empty for default.",
+ "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt_hash], [prompt], [prompt_no_styles], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [model_name], [prompt_words], [date], [datetime], [datetime<Format>], [datetime<Format><Time Zone>], [job_timestamp]; leave empty for default.",
+ "Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg],[prompt_hash], [prompt], [prompt_no_styles], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [model_name], [prompt_words], [date], [datetime], [datetime<Format>], [datetime<Format><Time Zone>], [job_timestamp]; leave empty for default.",
"Max prompt words": "Set the maximum number of words to be used in the [prompt_words] option; ATTENTION: If the words are too long, they may exceed the maximum length of the file path that the system can handle",
"Loopback": "Process an image, use it as an input, repeat.",
diff --git a/javascript/ui.js b/javascript/ui.js
index ba72623c..b7a8268a 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -191,6 +191,28 @@ function confirm_clear_prompt(prompt, negative_prompt) {
return [prompt, negative_prompt]
}
+
+promptTokecountUpdateFuncs = {}
+
+function recalculatePromptTokens(name){
+ if(promptTokecountUpdateFuncs[name]){
+ promptTokecountUpdateFuncs[name]()
+ }
+}
+
+function recalculate_prompts_txt2img(){
+ recalculatePromptTokens('txt2img_prompt')
+ recalculatePromptTokens('txt2img_neg_prompt')
+ return args_to_array(arguments);
+}
+
+function recalculate_prompts_img2img(){
+ recalculatePromptTokens('img2img_prompt')
+ recalculatePromptTokens('img2img_neg_prompt')
+ return args_to_array(arguments);
+}
+
+
opts = {}
onUiUpdate(function(){
if(Object.keys(opts).length != 0) return;
@@ -232,14 +254,12 @@ onUiUpdate(function(){
return
}
-
prompt.parentElement.insertBefore(counter, prompt)
counter.classList.add("token-counter")
prompt.parentElement.style.position = "relative"
- textarea.addEventListener("input", function(){
- update_token_counter(id_button);
- });
+ promptTokecountUpdateFuncs[id] = function(){ update_token_counter(id_button); }
+ textarea.addEventListener("input", promptTokecountUpdateFuncs[id]);
}
registerTextarea('txt2img_prompt', 'txt2img_token_counter', 'txt2img_token_button')
@@ -273,7 +293,7 @@ onOptionsChanged(function(){
let txt2img_textarea, img2img_textarea = undefined;
let wait_time = 800
-let token_timeout;
+let token_timeouts = {};
function update_txt2img_tokens(...args) {
update_token_counter("txt2img_token_button")
@@ -290,9 +310,9 @@ function update_img2img_tokens(...args) {
}
function update_token_counter(button_id) {
- if (token_timeout)
- clearTimeout(token_timeout);
- token_timeout = setTimeout(() => gradioApp().getElementById(button_id)?.click(), wait_time);
+ if (token_timeouts[button_id])
+ clearTimeout(token_timeouts[button_id]);
+ token_timeouts[button_id] = setTimeout(() => gradioApp().getElementById(button_id)?.click(), wait_time);
}
function restart_reload(){
@@ -309,3 +329,10 @@ function updateInput(target){
Object.defineProperty(e, "target", {value: target})
target.dispatchEvent(e);
}
+
+
+var desiredCheckpointName = null;
+function selectCheckpoint(name){
+ desiredCheckpointName = name;
+ gradioApp().getElementById('change_checkpoint').click()
+}