Compare commits

..

4 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
Dominik Reh
c7258a5839 Hotfix for duplicates not recognized as changes 2022-10-11 22:43:04 +02:00
Dominik Reh
a94be12e86 Fix default values 2022-10-11 22:17:19 +02:00
Dominik Reh
4047e2da3d Update README.md 2022-10-11 22:15:10 +02:00
Dominik Reh
c4ad9f250d Update README.md 2022-10-11 22:14:53 +02:00
3 changed files with 14 additions and 7 deletions

View File

@@ -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.

View File

@@ -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) {

View File

@@ -1,5 +1,5 @@
{
"tagFile": "danbooru.csv",
"maxResults": 10,
"replaceUnderscores": false
}
"maxResults": 5,
"replaceUnderscores": true
}