Init
parent
9988e25168
commit
c634fba4a0
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Haoming
|
||||
Copyright (c) 2023
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
|
|
@ -1,2 +1,6 @@
|
|||
# sd-webui-promptformat
|
||||
An Extention for Automatic1111 Webui that helps clean up prompts
|
||||
# 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.
|
||||
|
||||
### What This Does?
|
||||
- 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**.
|
||||
- Works for both `txt2img` and `img2img`.
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
class LeFormatter {
|
||||
|
||||
static injectTxt2ImgButton({
|
||||
onClick
|
||||
}) {
|
||||
const t2i_button = gradioApp().getElementById('txt2img_generate')
|
||||
t2i_button.addEventListener('click', onClick)
|
||||
}
|
||||
|
||||
static injectImg2ImgButton({
|
||||
onClick
|
||||
}) {
|
||||
const i2i_button = gradioApp().getElementById('img2img_generate')
|
||||
i2i_button.addEventListener('click', onClick)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
onUiLoaded(async () => {
|
||||
|
||||
LeFormatter.injectTxt2ImgButton({
|
||||
onClick: () => {
|
||||
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(', ');
|
||||
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(', ');
|
||||
updateInput(textareaN)
|
||||
}
|
||||
})
|
||||
|
||||
LeFormatter.injectImg2ImgButton({
|
||||
onClick: () => {
|
||||
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(', ');
|
||||
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(', ');
|
||||
updateInput(textareaN)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
Loading…
Reference in New Issue