Change blacklist to use model name instead of hash

Hotfix for recent webui changes to use proper sha256 hashes, which is currently not displayed in the UI
This commit is contained in:
Dominik Reh
2023-01-14 14:24:44 +01:00
parent c663abcbcb
commit a91a098243
2 changed files with 7 additions and 8 deletions

View File

@@ -266,7 +266,7 @@ function hideResults(textArea) {
selectedTag = null;
}
var currentModelHash = "";
var currentModelName = "";
// Function to check activation criteria
function isEnabled() {
if (CFG.activeIn.global) {
@@ -277,11 +277,11 @@ function isEnabled() {
if (CFG.activeIn.modelListMode.toLowerCase() === "blacklist") {
// If the current model is in the blacklist, disable
return !modelList.includes(currentModelHash);
return !modelList.includes(currentModelName);
} else {
// If the current model is in the whitelist, enable.
// An empty whitelist is ignored.
return modelList.length === 0 || modelList.includes(currentModelHash);
return modelList.length === 0 || modelList.includes(currentModelName);
}
} else {
return false;
@@ -293,7 +293,6 @@ const TAG_REGEX = /(<[^\t\n\r,>]+>?|[^\s,|<>]+|<)/g
const WC_REGEX = /\b__([^, ]+)__([^, ]*)\b/g;
const UMI_PROMPT_REGEX = /<[^\s]*?\[[^,<>]*[\]|]?>?/gi;
const UMI_TAG_REGEX = /(?:\[|\||--)([^<>\[\]\-|]+)/gi;
const MODEL_HASH_REGEX = /\[(.+)\]/g;
let hideBlocked = false;
// On click, insert the tag into the prompt textbox with respect to the cursor position
@@ -1103,10 +1102,10 @@ async function setup() {
});
// Add change listener to model dropdown to react to model changes
let modelDropdown = gradioApp().querySelector("#setting_sd_model_checkpoint select");
currentModelHash = [...modelDropdown.value.matchAll(MODEL_HASH_REGEX)][0][1]; // Set initial model hash
currentModelName = modelDropdown.value;
modelDropdown.addEventListener("change", () => {
setTimeout(() => {
currentModelHash = [...modelDropdown.value.matchAll(MODEL_HASH_REGEX)][0][1];
currentModelName = modelDropdown.value;
}, 100);
});

View File

@@ -215,8 +215,8 @@ def on_ui_settings():
shared.opts.add_option("tac_activeIn.img2img", shared.OptionInfo(True, "Active in img2img (Requires restart)", section=TAC_SECTION))
shared.opts.add_option("tac_activeIn.negativePrompts", shared.OptionInfo(True, "Active in negative prompts (Requires restart)", section=TAC_SECTION))
shared.opts.add_option("tac_activeIn.thirdParty", shared.OptionInfo(True, "Active in third party textboxes [Dataset Tag Editor] (Requires restart)", section=TAC_SECTION))
shared.opts.add_option("tac_activeIn.modelList", shared.OptionInfo("", "List of model hashes to use as black/whitelist, separated by commas.", section=TAC_SECTION))
shared.opts.add_option("tac_activeIn.modelListMode", shared.OptionInfo("Blacklist", "Mode to use for model hash list", gr.Dropdown, lambda: {"choices": ["Blacklist","Whitelist"]}, section=TAC_SECTION))
shared.opts.add_option("tac_activeIn.modelList", shared.OptionInfo("", "List of model names (with file extension) to use as black/whitelist, separated by commas.", section=TAC_SECTION))
shared.opts.add_option("tac_activeIn.modelListMode", shared.OptionInfo("Blacklist", "Mode to use for model list", gr.Dropdown, lambda: {"choices": ["Blacklist","Whitelist"]}, section=TAC_SECTION))
# Results related settings
shared.opts.add_option("tac_maxResults", shared.OptionInfo(5, "Maximum results", section=TAC_SECTION))
shared.opts.add_option("tac_showAllResults", shared.OptionInfo(False, "Show all results", section=TAC_SECTION))