Now format sentences too

- Added RE for handling spaces
- Added Demo Image
pull/4/head
Haoming 2023-05-05 11:06:48 +08:00
parent 54d32b9b63
commit 7b849d94d1
3 changed files with 10 additions and 4 deletions

BIN
Demo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -1,6 +1,8 @@
# SD Webui Prompt Format
This is an Extension for the [Automatic1111 Webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui), which aims to help formatting prompts upon generation.
<p align="center"><img src="Demo.jpg"></p>
## What is This ?
- Sometimes when you are typing too fast or are copying tags from all over the places, you end up with duplicated spaces or commas.
- This simple script helps removing them whenever you click **Generate**.

View File

@ -24,12 +24,14 @@ onUiLoaded(async () => {
const idP = 'txt2img_prompt'
const textareaP = gradioApp().getElementById(idP).querySelector('textarea')
const tagsP = textareaP.value.split(',').map(word => word.trim()).filter(word => word !== '');
textareaP.value = tagsP.join(', ');
const sentenceP = tagsP.join(', ');
textareaP.value = sentenceP.replace(/\s+/g, ' ').trim();
updateInput(textareaP)
const idN = 'txt2img_neg_prompt'
const textareaN = gradioApp().getElementById(idN).querySelector('textarea')
const tagsN = textareaN.value.split(',').map(word => word.trim()).filter(word => word !== '');
textareaN.value = tagsN.join(', ');
const sentenceN = tagsN.join(', ');
textareaN.value = sentenceN.replace(/\s+/g, ' ').trim();
updateInput(textareaN)
}
})
@ -39,12 +41,14 @@ onUiLoaded(async () => {
const idP = 'img2img_prompt'
const textareaP = gradioApp().getElementById(idP).querySelector('textarea')
const tagsP = textareaP.value.split(',').map(word => word.trim()).filter(word => word !== '');
textareaP.value = tagsP.join(', ');
const sentenceP = tagsP.join(', ');
textareaP.value = sentenceP.replace(/\s+/g, ' ').trim();
updateInput(textareaP)
const idN = 'img2img_neg_prompt'
const textareaN = gradioApp().getElementById(idN).querySelector('textarea')
const tagsN = textareaN.value.split(',').map(word => word.trim()).filter(word => word !== '');
textareaN.value = tagsN.join(', ');
const sentenceN = tagsN.join(', ');
textareaN.value = sentenceN.replace(/\s+/g, ' ').trim();
updateInput(textareaN)
}
})