version up

This commit is contained in:
lilly
2023-03-21 02:17:27 +09:00
parent 9251b2587d
commit 35efbbe2af
2 changed files with 76 additions and 11 deletions
+10
View File
@@ -14,6 +14,16 @@ a{__b__|{c|}|{__d__|e|}|f|}g____ __my__
- to
aeg __quality_my__, __breasts__, { |__character_dress__|__dress_my__}, __shoulder__, {high heels,| } {choker,| } {<lora:__lora_lst__:__rora_num__>,| } NSFW, __NSFW_my__, { |__style_my__,}
```
ex : {3$$a1|{b2|c3|}|d4|{-$$|f|g}|{-2$$h||i}|{1-$$j|k|}}/{$$l|m|}/{0$$n|}
{1|2|3} -> 1 or 2 or 3
{2$$a|b|c} -> a,b or b,c or c,a or bb or ....
{9$$a|b|c} -> {3$$a|b|c} auto fix max count
{1-2$$a|b|c} -> 1~2 random choise
{-2$$a|b|c} -> {0-2$$a|b|c} 0-2
{1-$$a|b|c} -> {0-3$$a|b|c} 1-max
{-$$a|b|c} -> {0-3$$a|b|c} 0-max
```
### run sample
+66 -11
View File
@@ -30,23 +30,77 @@ card_path=os.path.dirname(__file__)+"\\..\\..\\wildcards\\**\\*.txt"
print(f"wildcards card_path {card_path}")
# 정규식
resub = re.compile(r"(\{)([^\{\}]*)(\})")
#resub = re.compile(r"(\{)([^\{\}]*)(\})")
resub = re.compile(r"(\{)(((\d+)|(\d+)?-(\d+)?)?\$\$)?([^\{\}]*)(\})")
recard = re.compile(r"(__)(.*?)(__)")
# 카드 목록
cards = {}
seperator=", "
loop_max=50
# | 로 입력된것중 하나 가져오기
def sub(match):
m=match.group(2).split("|")
#print(f"sub : {m}")
return random.choice(m)
#print(f"sub : {(match.groups())}")
try:
#m=match.group(2)
s=match.group(3)
m=match.group(7).split("|")
#print(f"m : {m}")
if s is None:
return random.choice(m)
c=len(m)
n=int(match.group(4)) if match.group(4) else None
if n:
r=seperator.join(random.sample(m,min(n,c)))
#print(f"n : {n} ; {r}")
return r
n1=match.group(5)
n2=match.group(6)
if n1 or n2:
a=min(int(n1 if n1 else c), int(n2 if n2 else c),c)
b=min(max(int(n1 if n1 else 0), int(n2 if n2 else 0)),c)
#print(f"ab : {a} ; {b}")
r=seperator.join(
random.sample(
m,
random.randint(
a,b
)
)
)
#n1=int(match.group(5)) if not match.group(5) is None
#n2=int(match.group(6)) if not match.group(6) is None
else:
r=seperator.join(
random.sample(
m,
random.randint(
0,c
)
)
)
#print(f"12 : {r}")
return r
except Exception as e:
print(f"Error : {match.groups()}")
print(f"Exception : {e}")
return ""
# | 로 입력된것중 하나 가져오기 반복
def sub_loop(text):
bak=text
for i in range(1, 50):
for i in range(1, loop_max):
tmp=resub.sub(sub, bak)
#print(f"tmp : {tmp}")
if bak==tmp :
return tmp
bak=tmp
@@ -66,7 +120,7 @@ def card(match):
# 카드 중에서 가져오기 반복. | 의 것도 처리
def card_loop(text):
bak=text
for i in range(1, 50):
for i in range(1, loop_max):
tmp=recard.sub(card, bak)
#print(f"card l : {bak}")
if bak==tmp :
@@ -117,10 +171,11 @@ def run(text):
# ============================================================
# 테스트용
test="__my__"
#m = p.sub(sub, test)
#print(m)
run(test)
#print(__name__)
if __name__ == '__main__' :
# 테스트용
test="{3$$a1|{b2|c3|}|d4|{-$$|f|g}|{-2$$h||i}|{1-$$j|k|}}/{$$l|m|}/{0$$n|}"
print(run(test))
print(run("{9$$a|b}"))