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 | |
|---|---|---|---|
|
|
c7258a5839 | ||
|
|
a94be12e86 | ||
|
|
4047e2da3d | ||
|
|
c4ad9f250d |
@@ -7,7 +7,7 @@ Since some Stable Diffusion models were trained using this information, for exam
|
||||
|
||||
I created this script as a convenience tool since it reduces the need of switching back and forth between the web UI and a booru site to copy-paste tags.
|
||||
|
||||
[[Setup instructions]](#installation)
|
||||
You can either download the files manually as described below, or use a pre-packaged version from [Releases](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/releases).
|
||||
|
||||
### Disclaimer:
|
||||
This script is definitely not optimized, and it's not very intelligent. The tags are simply recommended based on their natural order in the CSV, which is their respective image count for the default Danbooru tag list. Also, at least for now, neither keyboard selection for tags nor completion for negative or img2img prompt textboxes is supported, and there's no way to turn the feature off from the ui, but I plan to get around to those features eventually.
|
||||
|
||||
@@ -110,6 +110,13 @@ const debounce = (func, wait = 300) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Difference function to fix duplicates not being seen as changes in normal filter
|
||||
function difference(a, b) {
|
||||
return [...b.reduce( (acc, v) => acc.set(v, (acc.get(v) || 0) - 1),
|
||||
a.reduce( (acc, v) => acc.set(v, (acc.get(v) || 0) + 1), new Map() )
|
||||
)].reduce( (acc, [v, count]) => acc.concat(Array(Math.abs(count)).fill(v)), [] );
|
||||
}
|
||||
|
||||
// Create the result list div and necessary styling
|
||||
function createResultsDiv() {
|
||||
let resultsDiv = document.createElement("div");
|
||||
@@ -186,16 +193,16 @@ function autocomplete(prompt) {
|
||||
|
||||
// Match tags with RegEx to get the last edited one
|
||||
let tags = prompt.match(/[^, ]+/g);
|
||||
let difference = tags.filter(x => !previousTags.includes(x));
|
||||
let diff = difference(tags, previousTags)
|
||||
previousTags = tags;
|
||||
|
||||
// Guard for no difference / only whitespace remaining
|
||||
if (difference == undefined || difference.length == 0) {
|
||||
if (diff == undefined || diff.length == 0) {
|
||||
hideResults();
|
||||
return;
|
||||
}
|
||||
|
||||
let tagword = difference[0]
|
||||
let tagword = diff[0]
|
||||
|
||||
// Guard for empty tagword
|
||||
if (tagword == undefined || tagword.length == 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"tagFile": "danbooru.csv",
|
||||
"maxResults": 10,
|
||||
"replaceUnderscores": false
|
||||
}
|
||||
"maxResults": 5,
|
||||
"replaceUnderscores": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user