add dynamic mutipul classes

pull/20/head
thisjam 2023-08-21 21:04:36 +08:00
parent bbb0ee6210
commit 50e23966d8
4 changed files with 24 additions and 14 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
/scripts/__pycache__/
/yours/*
!/yours/.gitkeep
__pycache__
*.git*
*.swp

View File

@ -1,13 +1,13 @@

# sd-webui-oldsix_prompt v1.32
# sd-webui-oldsix_prompt v1.33
### 老版词库 @路过银河&网上收集
### 新词库由群里小伙伴 @麻瓜 @万碎爷 @元一斤 整理
### 100%完全自制插件不是魔改别人最近有个别up未均本人允许在多个平台打着nsfw词库的旗号拿本插件吸粉入群别人安装插件出问题又无法提供解决方案 ###
### 觉得好用的可以给我点颗星。
#### 英文不好不用怕彻底解决prompt对于国人不友好的痛点整理了多个分类上千个提示词无需英文快速输入提示词
#### 词库会持续更新
* AI交流Q群875376246 各种疑难解答 帮你踩坑
* AI交流Q群390942276 各种疑难解答 帮你踩坑
* 已分好类别的词库,不会做太大改动,尽量不破坏大家的使用习惯
---
* 特别鸣谢群里兄弟们的支持
@ -26,7 +26,7 @@
* 左键输入正向提示框、 右键输入负向提示框
* 支持自定义词库
* 支持随机抽卡 【灵感模式、分类随机模式】
* 支持动态随机提示词 本插件专属语法示例:#[red#blue#yellow] 或#[日常服饰]
* 支持动态随机提示词 本插件专属语法示例:#[red#blue#yellow] 或#[日常服饰]、 #[红色类#黄色类]
---
##### 展示1
![Image text](imgs/1.png)

View File

@ -79,13 +79,15 @@ class Script(scripts.Script):
eid='oldsix-prompt1'
tid='oldsix-area1'
with gr.Row(elem_id=eid):
with gr.Accordion(label="SixGod_K提示词 v1.32",open=False):
with gr.Accordion(label="SixGod_K提示词 v1.33",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")
with gr.Column(scale=4,elem_id="oldsix-optit"):
gr.HTML('<p class="oldsix-classes-shop"></p>')
with gr.Accordion(label="随机灵感",open=False):
@ -129,15 +131,22 @@ def extract_classesTags(p):
pattern = r'#\[(.*?)\]'
matches=re.findall(pattern, p.prompt)
if(len(matches)==0) :
return
for key in matches:
if(key in listdynamice):
newtext=''
for item in listdynamice[key]:
newtext+=listdynamice[key][item]+'#'
p.prompt=p.prompt.replace(key,newtext,1)
pass
return
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
def extract_tags(p):
pattern = r'#\[(.*?)\]'