add fixed batch prompts
parent
50e23966d8
commit
6b4f887a9c
|
|
@ -1,11 +1,8 @@
|
|||
/cache/*
|
||||
/scripts/__pycache__
|
||||
/scripts/__pycache__/*
|
||||
/scripts/__pycache__/
|
||||
/yours/*
|
||||
!/yours/.gitkeep
|
||||
__pycache__
|
||||
|
||||
/scripts/__pycache__
|
||||
/scripts/__pycache__/*
|
||||
*.git*
|
||||
*.swp
|
||||
*.pyc
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
|
||||
# sd-webui-oldsix_prompt v1.33
|
||||
# sd-webui-oldsix_prompt v1.33.3
|
||||
### 老版词库 @路过银河&网上收集
|
||||
### 新词库由群里小伙伴 @麻瓜 @万碎爷 @元一斤 整理
|
||||
### 100%完全自制插件,不是魔改别人,最近有个别up未均本人允许,在多个平台打着nsfw词库的旗号拿本插件吸粉入群,别人安装插件出问题又无法提供解决方案 ###
|
||||
|
|
@ -9,6 +9,8 @@
|
|||
#### 词库会持续更新
|
||||
* AI交流Q群390942276 各种疑难解答 帮你踩坑
|
||||
* 已分好类别的词库,不会做太大改动,尽量不破坏大家的使用习惯
|
||||
* webUI1.21以下版本不支持,如果无法显示词库请升级webUI到最新,尤其是linux云端用户,部署的可能是古老版本的环境,请升级到新版webUI
|
||||
|
||||
---
|
||||
* 特别鸣谢群里兄弟们的支持
|
||||
<p> @六尘、@以及不愿意透露姓名的水友们</p>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
let Elements;
|
||||
function loadNodes() {
|
||||
let Elements = {
|
||||
prompt: getEle('#oldsix-prompt1'),
|
||||
|
|
@ -349,7 +349,10 @@ function move(){
|
|||
Elements = loadNodes()
|
||||
Elements.txt2img.appendChild(Elements.prompt)
|
||||
Elements.img2img.appendChild(Elements.prompt2)
|
||||
|
||||
let checkboxParents= getEleAll('.oldsix-checklock')
|
||||
checkboxParents.forEach(item=>{
|
||||
item.parentElement.classList.add('oldsix-inline')
|
||||
})
|
||||
}
|
||||
|
||||
function clearPrompt(pageindex){
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -60,6 +60,7 @@ class Script(scripts.Script):
|
|||
json= LoadTagsFile()
|
||||
randomIndex=0
|
||||
txtprompt=None
|
||||
isLockPrompt=False
|
||||
|
||||
def after_component(self, component, **kwargs):
|
||||
if(component.elem_id=="txt2img_prompt" or component.elem_id=="img2img_prompt"):
|
||||
|
|
@ -79,14 +80,17 @@ class Script(scripts.Script):
|
|||
eid='oldsix-prompt1'
|
||||
tid='oldsix-area1'
|
||||
with gr.Row(elem_id=eid):
|
||||
with gr.Accordion(label="SixGod_K提示词 v1.33",open=False):
|
||||
with gr.Accordion(label="SixGod_K提示词 v1.34",open=False):
|
||||
gr.HTML('<a href="https://github.com/thisjam/sd-webui-oldsix-prompt/">【使用说明书】</a>')
|
||||
|
||||
textarea=gr.TextArea(self.json,elem_id=tid,visible=False)
|
||||
|
||||
with gr.Column(scale=4,elem_id="oldsix-optit"):
|
||||
btnreload=gr.Button('🔄',elem_classes="oldsix-reload sm secondary gradio-button svelte-1ipelgc")
|
||||
gr.Button('清空正面提示词', variant="secondary",elem_classes="oldsix-clear")
|
||||
gr.Button('清空负面提示词',variant="secondary",elem_classes="oldsix-clear")
|
||||
chDynamic=gr.Checkbox(label="锁定【动态批次】提示词",elem_classes="oldsix-checklock",container=False,scale=1)
|
||||
|
||||
|
||||
with gr.Column(scale=4,elem_id="oldsix-optit"):
|
||||
gr.HTML('<p class="oldsix-classes-shop"></p>')
|
||||
|
|
@ -114,53 +118,80 @@ class Script(scripts.Script):
|
|||
return [self.rdlist[self.randomIndex]['val'],rden]
|
||||
def reloadData():
|
||||
return LoadTagsFile()
|
||||
|
||||
|
||||
def CheckboxChange(input):
|
||||
self.isLockPrompt=input
|
||||
return input
|
||||
|
||||
|
||||
btnreload.click(fn=reloadData,inputs=None,outputs=textarea)
|
||||
btnRandom.click(fn=randomPrompt,inputs=None,outputs=[rdtextareaEn,rdtextareaZh])
|
||||
btnRandom.click(fn=randomPrompt,inputs=None,outputs=[rdtextareaEn,rdtextareaZh])
|
||||
chDynamic.select(fn=CheckboxChange,inputs=chDynamic,outputs=chDynamic,show_progress=False)
|
||||
|
||||
return [btnreload]
|
||||
|
||||
|
||||
def before_process(self, p, *args):
|
||||
extract_classesTags(p)
|
||||
extract_tags(p)
|
||||
pass
|
||||
|
||||
|
||||
def before_process(self, p, *args):
|
||||
if(self.isLockPrompt):
|
||||
temppromt= extract_classesTags(p.prompt)
|
||||
if(temppromt):
|
||||
res=extract_tags(temppromt)
|
||||
if(res):
|
||||
p.prompt=res
|
||||
|
||||
def process(self, p, *args):
|
||||
if(not self.isLockPrompt):
|
||||
for index,val in enumerate(p.all_prompts):
|
||||
temppromt=extract_classesTags(p.prompt)
|
||||
if(temppromt):
|
||||
res=extract_tags(temppromt)
|
||||
if(res):
|
||||
p.all_prompts[index]=res
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def extract_classesTags(p):
|
||||
def extract_classesTags(prompt):
|
||||
pattern = r'#\[(.*?)\]'
|
||||
matches=re.findall(pattern, p.prompt)
|
||||
matches=re.findall(pattern, prompt)
|
||||
if(len(matches)==0) :
|
||||
return
|
||||
return None
|
||||
for mathch in matches:
|
||||
arr=mathch.split('#')
|
||||
randlist=[]
|
||||
for classesKey in arr:
|
||||
if(classesKey in listdynamice):
|
||||
randlist.append(listdynamice[classesKey])
|
||||
if len(randlist)==0: continue
|
||||
random.seed(getSeed())
|
||||
rdindex=random.randint(0,len(randlist)-1)
|
||||
newtext=''
|
||||
for item in randlist[rdindex]:
|
||||
newtext+=randlist[rdindex][item]+'#'
|
||||
p.prompt=p.prompt.replace(mathch,newtext,1)
|
||||
pass
|
||||
arr=mathch.split('#')
|
||||
randlist=[]
|
||||
for classesKey in arr:
|
||||
if(classesKey in listdynamice):
|
||||
randlist.append(listdynamice[classesKey])
|
||||
if len(randlist)==0: continue
|
||||
random.seed(getSeed())
|
||||
rdindex=random.randint(0,len(randlist)-1)
|
||||
newtext=''
|
||||
for item in randlist[rdindex]:
|
||||
newtext+=randlist[rdindex][item]+'#'
|
||||
prompt=prompt.replace(mathch,newtext,1)
|
||||
return prompt
|
||||
|
||||
|
||||
def extract_tags(p):
|
||||
def extract_tags(prompt):
|
||||
pattern = r'#\[(.*?)\]'
|
||||
matches = re.findall(pattern, p.prompt)
|
||||
text=p.prompt
|
||||
matches = re.findall(pattern, prompt)
|
||||
text=prompt
|
||||
if(len(matches)==0) :
|
||||
return
|
||||
return None
|
||||
for item in matches:
|
||||
arr=item.split('#')
|
||||
random.seed(getSeed())
|
||||
rdindex=random.randint(0,len(arr)-1)
|
||||
rdtext=arr[rdindex]
|
||||
text = re.sub(pattern, rdtext, text,count=1)
|
||||
p.prompt=text
|
||||
return text
|
||||
|
||||
|
||||
def getSeed():
|
||||
|
|
|
|||
Loading…
Reference in New Issue