Skip to content

Commit

Permalink
Merge pull request lllyasviel#129 from AIrjen/OBP_Preset_randomizer
Browse files Browse the repository at this point in the history
Added option to run OBP Presets randomly
  • Loading branch information
runew0lf authored Feb 25, 2024
2 parents 2d6c7b2 + 89dc286 commit cda4cbd
Show file tree
Hide file tree
Showing 15 changed files with 590,681 additions and 44 deletions.
20 changes: 18 additions & 2 deletions modules/prompt_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@ def process_wildcards(wildcard_text, directory="wildcards"):

if placeholder.startswith("onebuttonprompt"):
random_choice = build_dynamic_prompt(
insanitylevel=5, givensubject=subjectoverride
insanitylevel=5,
givensubject=subjectoverride,
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonsubject"):
random_choice = build_dynamic_prompt(
insanitylevel=5,
imagetype="subject only mode",
givensubject=subjectoverride,
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonhumanoid"):
random_choice = build_dynamic_prompt(
Expand All @@ -105,6 +109,7 @@ def process_wildcards(wildcard_text, directory="wildcards"):
givensubject=subjectoverride,
forcesubject="humanoid",
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonmale"):
random_choice = build_dynamic_prompt(
Expand All @@ -114,6 +119,7 @@ def process_wildcards(wildcard_text, directory="wildcards"):
forcesubject="humanoid",
gender="male",
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonfemale"):
random_choice = build_dynamic_prompt(
Expand All @@ -123,6 +129,7 @@ def process_wildcards(wildcard_text, directory="wildcards"):
forcesubject="humanoid",
gender="female",
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonanimal"):
random_choice = build_dynamic_prompt(
Expand All @@ -131,6 +138,7 @@ def process_wildcards(wildcard_text, directory="wildcards"):
givensubject=subjectoverride,
forcesubject="animal",
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonobject"):
random_choice = build_dynamic_prompt(
Expand All @@ -139,6 +147,7 @@ def process_wildcards(wildcard_text, directory="wildcards"):
givensubject=subjectoverride,
forcesubject="object",
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonlandscape"):
random_choice = build_dynamic_prompt(
Expand All @@ -147,6 +156,7 @@ def process_wildcards(wildcard_text, directory="wildcards"):
givensubject=subjectoverride,
forcesubject="landscape",
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonconcept"):
random_choice = build_dynamic_prompt(
Expand All @@ -155,13 +165,15 @@ def process_wildcards(wildcard_text, directory="wildcards"):
givensubject=subjectoverride,
forcesubject="concept",
advancedprompting=False,
base_model="SDXL",
)
elif placeholder.startswith("onebuttonartist"):
random_choice = build_dynamic_prompt(
insanitylevel=5,
onlyartists=True,
artists=subjectoverride or "all",
advancedprompting=False,
base_model="SDXL",
)
# failover
else:
Expand All @@ -170,6 +182,7 @@ def process_wildcards(wildcard_text, directory="wildcards"):
imagetype="subject only mode",
givensubject=subjectoverride,
advancedprompting=False,
base_model="SDXL",
)

# Regular wildcards
Expand Down Expand Up @@ -202,7 +215,10 @@ def process_prompt(style, prompt, negative, gen_data=[]):
suffixprompt=gen_data["obp_suffixprompt"],
giventypeofimage=gen_data["obp_giventypeofimage"],
antivalues=gen_data["obp_antistring"],
OBP_preset=gen_data["OBP_preset"],
advancedprompting=False,
base_model="SDXL",

)
pattern = re.compile(r"<style:([^>]+)>")
styles = [] if style is None else style.copy()
Expand All @@ -220,7 +236,7 @@ def process_prompt(style, prompt, negative, gen_data=[]):

# apply auto negative prompt if enabled
if(gen_data["auto_negative"] == True):
n_txt = build_dynamic_negative(positive_prompt=p_txt,existing_negative_prompt=n_txt)
n_txt = build_dynamic_negative(positive_prompt=p_txt,existing_negative_prompt=n_txt,base_model="SDXL")
return p_txt, n_txt


Expand Down
Loading

0 comments on commit cda4cbd

Please sign in to comment.