@@ -15,14 +15,14 @@ def title(self):
1515 def show (self , is_img2img ):
1616 return scripts .AlwaysVisible
1717
18- def replace_wildcard (self , text ):
18+ def replace_wildcard (self , text , gen ):
1919 if " " in text or len (text ) == 0 :
2020 return text
2121
2222 replacement_file = os .path .join (wildcard_dir , "wildcards" , f"{ text } .txt" )
2323 if os .path .exists (replacement_file ):
2424 with open (replacement_file , encoding = "utf8" ) as f :
25- return random .choice (f .read ().splitlines ())
25+ return gen .choice (f .read ().splitlines ())
2626 else :
2727 if replacement_file not in warned_about_files :
2828 print (f"File { replacement_file } not found for the __{ text } __ wildcard." , file = sys .stderr )
@@ -34,10 +34,11 @@ def process(self, p):
3434 original_prompt = p .all_prompts [0 ]
3535
3636 for i in range (len (p .all_prompts )):
37- random .seed (p .all_seeds [0 if shared .opts .wildcards_same_seed else i ])
37+ gen = random .Random ()
38+ gen .seed (p .all_seeds [0 if shared .opts .wildcards_same_seed else i ])
3839
3940 prompt = p .all_prompts [i ]
40- prompt = "" .join (self .replace_wildcard (chunk ) for chunk in prompt .split ("__" ))
41+ prompt = "" .join (self .replace_wildcard (chunk , gen ) for chunk in prompt .split ("__" ))
4142 p .all_prompts [i ] = prompt
4243
4344 if original_prompt != p .all_prompts [0 ]:
0 commit comments