Merge pull request #98 from AIrjen/fix_for_v15_and_new_sizes_for_SDXL
Fix for issue in 1.5
This commit is contained in:
+19
-9
@@ -9,7 +9,7 @@ from model_lists import *
|
||||
import time
|
||||
import random
|
||||
|
||||
def call_txt2img(passingprompt,ratio,upscale,debugmode,filename="",model = "currently selected model",samplingsteps = "40",cfg= "7",hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+",hiresscale="2",apiurl="http://127.0.0.1:7860", qualitygate=False,quality="7.6",runs="5",negativeprompt="",qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used"):
|
||||
def call_txt2img(passingprompt,ratio,upscale,debugmode,filename="",model = "currently selected model",samplingsteps = "40",cfg= "7",hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+",hiresscale="2",apiurl="http://127.0.0.1:7860", qualitygate=False,quality="7.6",runs="5",negativeprompt="",qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used", basesize="512"):
|
||||
|
||||
|
||||
|
||||
@@ -29,18 +29,28 @@ def call_txt2img(passingprompt,ratio,upscale,debugmode,filename="",model = "curr
|
||||
cfg_scale = cfg
|
||||
|
||||
#size
|
||||
if(ratio=='wide'):
|
||||
width = "768"
|
||||
height = "512"
|
||||
elif(ratio=='portrait'):
|
||||
width = "512"
|
||||
height = "768"
|
||||
# from base ratio
|
||||
if(ratio=='wide' and basesize != "1024"):
|
||||
width = str(int(basesize) + 256)
|
||||
height = basesize
|
||||
elif(ratio=='wide' and basesize == "1024"):
|
||||
width = "1152"
|
||||
height = "896"
|
||||
elif(ratio=='portrait' and basesize != "1024"):
|
||||
width = basesize
|
||||
height = str(int(basesize) + 256)
|
||||
elif(ratio=='portrait' and basesize == "1024"):
|
||||
width = "896"
|
||||
height = "1152"
|
||||
elif(ratio=='ultrawide'):
|
||||
width = "1280"
|
||||
height = "360"
|
||||
elif(ratio=='ultraheight'):
|
||||
width = "360"
|
||||
height = "1280"
|
||||
else:
|
||||
width = "512"
|
||||
height = "512"
|
||||
width = basesize
|
||||
height = basesize
|
||||
#upscaler
|
||||
enable_hr = upscale
|
||||
if(debugmode==1 or qualityhiresfix == True):
|
||||
|
||||
@@ -13,7 +13,7 @@ from call_extras import *
|
||||
from model_lists import *
|
||||
|
||||
|
||||
def generateimages(amount = 1, size = "all",model = "currently selected model",samplingsteps = "40",cfg= "7",hiresfix = True,hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+", hiresscale="2",apiurl="http://127.0.0.1:7860",qualitygate=False,quality="7.6",runs="5",insanitylevel="5",subject="all", artist="all", imagetype="all",silentmode=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma", img2imgbatch = "1", img2imgsamplingsteps = "20", img2imgcfg = "7", img2imgsamplingmethod = "DPM++ SDE Karras", img2imgupscaler = "R-ESRGAN 4x+", img2imgmodel = "currently selected model", img2imgactivate = False, img2imgscale = "2", img2imgpadding = "64",img2imgdenoisestrength="0.3",ultimatesdupscale=False,usdutilewidth = "512", usdutileheight = "0", usdumaskblur = "8", usduredraw ="Linear", usduSeamsfix = "None", usdusdenoise = "0.35", usduswidth = "64", usduspadding ="32", usdusmaskblur = "8",controlnetenabled=False, controlnetmodel="",img2imgdenoisestrengthmod="-0.05",enableextraupscale = False,controlnetblockymode = False,extrasupscaler1 = "all",extrasupscaler2 ="all",extrasupscaler2visiblity="0.5",extrasupscaler2gfpgan="0",extrasupscaler2codeformer="0.15",extrasupscaler2codeformerweight="0.1",extrasresize="2",onlyupscale="false",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20, gender="all", chosensubjectsubtypeobject="all", chosensubjectsubtypehumanoid="all", chosensubjectsubtypeconcept="all", increasestability = False, qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used"):
|
||||
def generateimages(amount = 1, size = "all",model = "currently selected model",samplingsteps = "40",cfg= "7",hiresfix = True,hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+", hiresscale="2",apiurl="http://127.0.0.1:7860",qualitygate=False,quality="7.6",runs="5",insanitylevel="5",subject="all", artist="all", imagetype="all",silentmode=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma", img2imgbatch = "1", img2imgsamplingsteps = "20", img2imgcfg = "7", img2imgsamplingmethod = "DPM++ SDE Karras", img2imgupscaler = "R-ESRGAN 4x+", img2imgmodel = "currently selected model", img2imgactivate = False, img2imgscale = "2", img2imgpadding = "64",img2imgdenoisestrength="0.3",ultimatesdupscale=False,usdutilewidth = "512", usdutileheight = "0", usdumaskblur = "8", usduredraw ="Linear", usduSeamsfix = "None", usdusdenoise = "0.35", usduswidth = "64", usduspadding ="32", usdusmaskblur = "8",controlnetenabled=False, controlnetmodel="",img2imgdenoisestrengthmod="-0.05",enableextraupscale = False,controlnetblockymode = False,extrasupscaler1 = "all",extrasupscaler2 ="all",extrasupscaler2visiblity="0.5",extrasupscaler2gfpgan="0",extrasupscaler2codeformer="0.15",extrasupscaler2codeformerweight="0.1",extrasresize="2",onlyupscale="false",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20, gender="all", chosensubjectsubtypeobject="all", chosensubjectsubtypehumanoid="all", chosensubjectsubtypeconcept="all", increasestability = False, qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used", basesize = "512"):
|
||||
loops = int(amount) # amount of images to generate
|
||||
steps = 0
|
||||
upscalefilelist=[]
|
||||
@@ -36,8 +36,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s
|
||||
originalimg2imgdenoisestrength = img2imgdenoisestrength
|
||||
originalimg2imgpadding = img2imgpadding
|
||||
|
||||
optionsresponse = requests.get(url=f'{apiurl}/sdapi/v1/options')
|
||||
optionsresponsejson = optionsresponse.json()
|
||||
|
||||
|
||||
modellist=get_models()
|
||||
samplerlist=get_samplers()
|
||||
@@ -45,9 +44,30 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s
|
||||
img2imgupscalerlist=get_upscalers_for_img2img()
|
||||
img2imgsamplerlist=get_samplers_for_img2img()
|
||||
|
||||
currentlyselectedmodel = optionsresponsejson["sd_model_checkpoint"]
|
||||
|
||||
tempmodel = "v1-5-pruned-emaonly.safetensors [6ce0161689]"
|
||||
|
||||
optionsresponse = requests.get(url=f'{apiurl}/sdapi/v1/options')
|
||||
optionsresponsejson = optionsresponse.json()
|
||||
|
||||
currentlyselectedmodelhash = optionsresponsejson["sd_checkpoint_hash"]
|
||||
|
||||
sdmodelsrespone = requests.get(url=f'{apiurl}/sdapi/v1/sd-models')
|
||||
sdmodelsresponsejson = sdmodelsrespone.json()
|
||||
|
||||
for item in sdmodelsresponsejson:
|
||||
if(item['sha256'] == currentlyselectedmodelhash):
|
||||
currentlyselectedmodel = item['title']
|
||||
break
|
||||
|
||||
# Print the 'title' if found
|
||||
if currentlyselectedmodel is not None:
|
||||
print("current selected model is:")
|
||||
print(currentlyselectedmodel)
|
||||
else:
|
||||
print("Cannot find current model.")
|
||||
currentlyselectedmodel = tempmodel
|
||||
|
||||
|
||||
while(currentlyselectedmodel == tempmodel or tempmodel not in modellist):
|
||||
tempmodel = random.choice(modellist)
|
||||
|
||||
@@ -187,7 +207,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s
|
||||
|
||||
|
||||
|
||||
txt2img = call_txt2img(randomprompt, size ,hiresfix, 0, filenamecomplete,model ,samplingsteps,cfg, hiressteps, denoisestrength,samplingmethod, upscaler,hiresscale,apiurl,qualitygate,quality,runs,negativeprompt, qualityhiresfix, qualitymode, qualitykeep)
|
||||
txt2img = call_txt2img(randomprompt, size ,hiresfix, 0, filenamecomplete,model ,samplingsteps,cfg, hiressteps, denoisestrength,samplingmethod, upscaler,hiresscale,apiurl,qualitygate,quality,runs,negativeprompt, qualityhiresfix, qualitymode, qualitykeep, basesize)
|
||||
originalimage = txt2img[0] #Set this for later use
|
||||
originalpnginfo = txt2img[1] #Sort of hacky way of bringing this forward. But if it works, it works
|
||||
continuewithnextpart = txt2img[2]
|
||||
|
||||
@@ -33,7 +33,8 @@ qualitymodelist = ["highest", "gated"]
|
||||
qualitykeeplist = ["keep used","keep all"]
|
||||
|
||||
#for autorun and upscale
|
||||
sizelist = ["all", "portrait", "wide", "square", "ultrawide"]
|
||||
sizelist = ["all", "portrait", "wide", "square", "ultrawide", "ultraheight"]
|
||||
basesizelist = ["512", "768", "1024"]
|
||||
|
||||
modellist = get_models()
|
||||
modellist.insert(0,"all")
|
||||
@@ -651,6 +652,8 @@ class Script(scripts.Script):
|
||||
amountofimages = gr.Slider(1, 50, value="20", step=1, label="Amount of images to generate")
|
||||
size = gr.Dropdown(
|
||||
sizelist, label="Size to generate", value="all")
|
||||
basesize = gr.Dropdown(
|
||||
basesizelist, label="base size", value="512")
|
||||
with gr.Row(scale=1):
|
||||
samplingsteps = gr.Slider(1, 100, value="20", step=1, label="Sampling steps")
|
||||
cfg = gr.Slider(1,20, value="6.0", step=0.1, label="CFG")
|
||||
@@ -785,7 +788,7 @@ class Script(scripts.Script):
|
||||
prompt4toworkflow.click(prompttoworkflowprompt, inputs=prompt4, outputs=workprompt)
|
||||
prompt5toworkflow.click(prompttoworkflowprompt, inputs=prompt5, outputs=workprompt)
|
||||
|
||||
startmain.click(generateimages, inputs=[amountofimages,size,model,samplingsteps,cfg,hiresfix,hiressteps,denoisestrength,samplingmethod, upscaler,hiresscale, apiurl, qualitygate, quality, runs,insanitylevel,subject, artist, imagetype, silentmode, workprompt, antistring, prefixprompt, suffixprompt,negativeprompt,promptcompounderlevel, seperator, img2imgbatch, img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel,img2imgactivate, img2imgscale, img2imgpadding,img2imgdenoisestrength,ultimatesdupscale,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur, controlnetenabled, controlnetmodel,img2imgdenoisestrengthmod,enableextraupscale,controlnetblockymode,extrasupscaler1,extrasupscaler2,extrasupscaler2visiblity,extrasupscaler2gfpgan,extrasupscaler2codeformer,extrasupscaler2codeformerweight,extrasresize,onlyupscale,givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, increasestability, qualityhiresfix, qualitymode, qualitykeep])
|
||||
startmain.click(generateimages, inputs=[amountofimages,size,model,samplingsteps,cfg,hiresfix,hiressteps,denoisestrength,samplingmethod, upscaler,hiresscale, apiurl, qualitygate, quality, runs,insanitylevel,subject, artist, imagetype, silentmode, workprompt, antistring, prefixprompt, suffixprompt,negativeprompt,promptcompounderlevel, seperator, img2imgbatch, img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel,img2imgactivate, img2imgscale, img2imgpadding,img2imgdenoisestrength,ultimatesdupscale,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur, controlnetenabled, controlnetmodel,img2imgdenoisestrengthmod,enableextraupscale,controlnetblockymode,extrasupscaler1,extrasupscaler2,extrasupscaler2visiblity,extrasupscaler2gfpgan,extrasupscaler2codeformer,extrasupscaler2codeformerweight,extrasresize,onlyupscale,givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, increasestability, qualityhiresfix, qualitymode, qualitykeep, basesize])
|
||||
|
||||
automatedoutputsfolderbutton.click(openfolder)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user