mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-01-27 03:29:55 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53899093c8 | ||
|
|
f9d98740f4 | ||
|
|
534f07225e | ||
|
|
b8b0673e2d |
@@ -132,10 +132,10 @@ function difference(a, b) {
|
||||
}
|
||||
// Get the identifier for the text area to differentiate between positive and negative
|
||||
function getTextAreaIdentifier(textArea) {
|
||||
let txt2img_n = gradioApp().querySelector('#negative_prompt > label > textarea');
|
||||
let txt2img_n = gradioApp().querySelector('#txt2img_neg_prompt > label > textarea');
|
||||
let img2img = gradioApp().querySelector('#tab_img2img');
|
||||
let img2img_p = img2img.querySelector('#img2img_prompt > label > textarea');
|
||||
let img2img_n = img2img.querySelector('#negative_prompt > label > textarea');
|
||||
let img2img_n = img2img.querySelector('#img2img_neg_prompt > label > textarea');
|
||||
|
||||
let modifier = "";
|
||||
if (textArea === img2img_p || textArea === img2img_n) {
|
||||
@@ -176,7 +176,7 @@ function createCheckbox() {
|
||||
input.setAttribute('type', 'checkbox');
|
||||
input.setAttribute('class', 'gr-check-radio gr-checkbox')
|
||||
span.setAttribute('class', 'ml-2');
|
||||
|
||||
|
||||
span.textContent = "Enable Autocomplete";
|
||||
|
||||
label.appendChild(input);
|
||||
@@ -234,10 +234,10 @@ function insertTextAtCursor(textArea, result, tagword) {
|
||||
|
||||
if (acConfig.escapeParentheses) {
|
||||
sanitizedText = sanitizedText
|
||||
.replaceAll("(", "\\(")
|
||||
.replaceAll(")", "\\)")
|
||||
.replaceAll("[", "\\[")
|
||||
.replaceAll("]", "\\]");
|
||||
.replaceAll("(", "\\(")
|
||||
.replaceAll(")", "\\)")
|
||||
.replaceAll("[", "\\[")
|
||||
.replaceAll("]", "\\]");
|
||||
}
|
||||
|
||||
var prompt = textArea.value;
|
||||
@@ -351,7 +351,7 @@ resultCount = 0;
|
||||
function autocomplete(textArea, prompt, fixedTag = null) {
|
||||
// Return if the function is deactivated in the UI
|
||||
if (!acActive) return;
|
||||
|
||||
|
||||
// Guard for empty prompt
|
||||
if (prompt.length === 0) {
|
||||
hideResults(textArea);
|
||||
@@ -526,8 +526,9 @@ onUiUpdate(function () {
|
||||
// Find all textareas
|
||||
let txt2imgTextArea = gradioApp().querySelector('#txt2img_prompt > label > textarea');
|
||||
let img2imgTextArea = gradioApp().querySelector('#img2img_prompt > label > textarea');
|
||||
let negativeTextAreas = Array.from(gradioApp().querySelectorAll('#negative_prompt > label > textarea'));
|
||||
let textAreas = [txt2imgTextArea, img2imgTextArea, negativeTextAreas[0], negativeTextAreas[1]];
|
||||
let txt2imgTextArea_n = gradioApp().querySelector('#txt2img_neg_prompt > label > textarea');
|
||||
let img2imgTextArea_n = gradioApp().querySelector('#img2img_neg_prompt > label > textarea');
|
||||
let textAreas = [txt2imgTextArea, img2imgTextArea, txt2imgTextArea_n, img2imgTextArea_n];
|
||||
|
||||
let quicksettings = gradioApp().querySelector('#quicksettings');
|
||||
|
||||
|
||||
@@ -10,19 +10,23 @@ EMB_PATH = os.path.join(FILE_DIR, 'embeddings')
|
||||
# The path to the temporary file
|
||||
TEMP_PATH = os.path.join(FILE_DIR, 'tags/temp')
|
||||
|
||||
|
||||
def get_wildcards():
|
||||
"""Returns a list of all wildcards"""
|
||||
return filter(lambda f: f.endswith(".txt"), os.listdir(WILDCARD_PATH))
|
||||
|
||||
|
||||
def get_embeddings():
|
||||
"""Returns a list of all embeddings"""
|
||||
return filter(lambda f: f.endswith(".bin") or f.endswith(".pt"), os.listdir(EMB_PATH))
|
||||
|
||||
|
||||
def write_to_temp_file(name, data):
|
||||
"""Writes the given data to a temporary file"""
|
||||
with open(os.path.join(TEMP_PATH, name), 'w') as f:
|
||||
with open(os.path.join(TEMP_PATH, name), 'w', encoding="utf-8") as f:
|
||||
f.write(('\n'.join(data)))
|
||||
|
||||
|
||||
# Check if the temp path exists and create it if not
|
||||
if not os.path.exists(TEMP_PATH):
|
||||
os.makedirs(TEMP_PATH)
|
||||
@@ -41,4 +45,4 @@ if os.path.exists(WILDCARD_PATH):
|
||||
if os.path.exists(EMB_PATH):
|
||||
embeddings = get_embeddings()
|
||||
if embeddings:
|
||||
write_to_temp_file('emb.txt', embeddings)
|
||||
write_to_temp_file('emb.txt', embeddings)
|
||||
|
||||
Reference in New Issue
Block a user