Merge pull request #117 from AIrjen/new_stuff

New stuff
This commit is contained in:
AIrjen
2023-08-11 18:51:32 +02:00
committed by GitHub
4 changed files with 63 additions and 8 deletions
+49 -2
View File
@@ -1236,6 +1236,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
completeprompt += "-culture- "
if(mainchooser == "object"):
# first add a wildcard that can be used to create prompt strenght
completeprompt += " -objectstrengthstart-"
# if we have an overwrite, then make sure we only take the override
if(subtypeobject != "all"):
if(subtypeobject == "generic objects"):
@@ -1281,8 +1283,12 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
completeprompt += " " + givensubject + " "
hybridorswap = ""
# completion of strenght end
completeprompt += "-objectstrengthend-"
if(mainchooser == "animal"):
# first add a wildcard that can be used to create prompt strenght
completeprompt += " -objectstrengthstart-"
# if we have a given subject, we should skip making an actual subject
if(givensubject == ""):
@@ -1312,9 +1318,14 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
completeprompt += " " + givensubject + " "
hybridorswap = ""
# completion of strenght end
completeprompt += "-objectstrengthend-"
# if we have a given subject, we should skip making an actual subject
if(mainchooser == "humanoid"):
# first add a wildcard that can be used to create prompt strenght
completeprompt += " -objectstrengthstart-"
if(givensubject==""):
if(subjectchooser == "human"):
@@ -1387,13 +1398,18 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
else:
completeprompt += " " + givensubject + " "
completeprompt += " " + givensubject + " "
# completion of strenght end
completeprompt += "-objectstrengthend-"
# sometimes add a suffix for more fun!
if( (mainchooser == "humanoid" or mainchooser == "animal" or mainchooser == "object") and chance_roll(insanitylevel, subjectconceptsuffixchance)):
completeprompt += " of -conceptsuffix- "
if(subjectchooser == "landscape"):
# first add a wildcard that can be used to create prompt strenght
completeprompt += " -objectstrengthstart-"
# if we have a given subject, we should skip making an actual subject
if(givensubject == ""):
@@ -1413,6 +1429,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
hybridorswap = ""
# completion of strenght end
completeprompt += "-objectstrengthend-"
# shots from inside can create cool effects in landscapes
if(chance_roll(insanitylevel, subjectlandscapeaddonlocationchance)):
insideshot = 1
@@ -1430,6 +1449,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
if(mainchooser == "concept"):
# first add a wildcard that can be used to create prompt strenght
completeprompt += " -objectstrengthstart-"
if(givensubject == ""):
if(subjectchooser == "event"):
completeprompt += " \"" + random.choice(eventlist) + "\" "
@@ -1445,7 +1466,10 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
else:
completeprompt += " " + givensubject + " "
# completion of strenght end
completeprompt += "-objectstrengthend-"
# object additions
for i in range(objectadditionsrepeats):
@@ -1938,7 +1962,30 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
# prompt strenght stuff
# if the given subject already is formed like this ( :1.x)
# then just ignore this
matches = []
if(givensubject != ""):
pattern = r'\(\w+:\d+\.\d+\)'
matches = re.findall(pattern, givensubject)
if(len(completeprompt) > 325 and matches == []):
if(len(completeprompt) < 375):
strenght = "1.1"
elif(len(completeprompt) < 450):
strenght = "1.2"
else:
strenght = "1.3"
completeprompt = completeprompt.replace("-objectstrengthstart-","(")
completeprompt = completeprompt.replace("-objectstrengthend-",":" + strenght + ")")
else:
completeprompt = completeprompt.replace("-objectstrengthstart-","")
completeprompt = completeprompt.replace("-objectstrengthend-","")
# clean it up
completeprompt = cleanup(completeprompt, advancedprompting)
+2 -1
View File
@@ -38,6 +38,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s
originalimg2imgpadding = img2imgpadding
currentlyselectedmodel = ""
modellist=get_models()
samplerlist=get_samplers()
@@ -61,7 +62,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s
break
# Print the 'title' if found
if currentlyselectedmodel is not None:
if currentlyselectedmodel != "":
print("current selected model is:")
print(currentlyselectedmodel)
else:
+11 -4
View File
@@ -1,6 +1,6 @@
import modules.scripts as scripts
import os
from modules import modelloader, paths, shared, sd_models
from modules import modelloader, paths, shared, sd_models, sd_samplers
from modules.paths import models_path, script_path
import importlib
@@ -32,9 +32,16 @@ def get_upscalers():
return upscalerlist
def get_samplers():
#Samplers are hardcoded in WEBui, so lets do it here as well
samplerlist = ["Euler a", "Euler", "LMS","Heun","DPM2","DPM2 a","DPM++ 2S a","DPM++ 2M","DPM++ SDE","DPM fast","DPM adaptive","LMS Karras","DPM2 Karras","DPM2 a Karras","DPM++ 2S a Karras","DPM++ 2M Karras","DPM++ SDE Karras"]
samplerlist += ["DDIM","UniPC", "PLMS"]
samplerlistfromWebUI = {x.name: x for x in sd_samplers.all_samplers}
samplerlist = list(samplerlistfromWebUI.keys())
# fallback method
# Samplers are hardcoded in WEBui, so lets do it here as well
if(samplerlist==[]):
samplerlist = ["Euler a", "Euler", "LMS","Heun","DPM2","DPM2 a","DPM++ 2S a","DPM++ 2M","DPM++ SDE","DPM fast","DPM adaptive","LMS Karras","DPM2 Karras","DPM2 a Karras","DPM++ 2S a Karras","DPM++ 2M Karras","DPM++ SDE Karras"]
samplerlist += ["DDIM","UniPC", "PLMS"]
return samplerlist
def get_upscalers_for_img2img():
+1 -1
View File
@@ -46,4 +46,4 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im
print("")
print("All done!")
generateprompts(10,5,"all","all","all",False,"","","PREFIXPROMPT" ,"SUFFIXPROMPT","",1,"","[hello there|cool man]",True,"",100, "all", "all", "all", "all", False)
generateprompts(10,8,"all","all","all",False,"","","PREFIXPROMPT" ,"SUFFIXPROMPT","",1,"","(hello:1.3)",True,"",100, "all", "all", "all", "all", False)