diff --git a/call_img2img.py b/call_img2img.py index 5a24c17..8bb7a29 100644 --- a/call_img2img.py +++ b/call_img2img.py @@ -100,7 +100,7 @@ def call_img2img(imagelocation,originalimage, originalpnginfo ="", apiurl="http: if(upscaler== "4x-UltraSharp"): denoising_strength = "0.35" - if(upscaler== "R-ESRGAN 4x+ Anime6B+"): + if(upscaler== "R-ESRGAN 4x+ Anime6B"): denoising_strength = "0.6" # 0.6 is fine for the anime upscaler if(upscaler== "R-ESRGAN 4x+"): denoising_strength = "0.5" # default 0.6 is a lot and changes a lot of details @@ -156,14 +156,14 @@ def call_img2img(imagelocation,originalimage, originalpnginfo ="", apiurl="http: }) if(upscalescript=="SD upscale"): payload.update({"script_name": upscalescript}) - payload.update({"script_args": ["",int(padding),upscaler,float(scale)]}) + payload.update({"script_args": ["",int(padding),upscaler,round(float(scale),1)]}) if(upscalescript=="Ultimate SD upscale"): upscaler_index = [x.name.lower() for x in shared.sd_upscalers].index(upscaler.lower()) payload.update({"script_name": upscalescript}) - payload.update({"script_args": ["",int(usdutilewidth),int(usdutileheight),int(usdumaskblur),int(padding), int(usduswidth), float(usdusdenoise),int(usduspadding), + payload.update({"script_args": ["",int(usdutilewidth),int(usdutileheight),int(usdumaskblur),int(padding), int(usduswidth), round(float(usdusdenoise),2),int(usduspadding), upscaler_index,True,usduredrawint,False,int(usdusmaskblur), - seamsfixmodeint,2,"","",float(scale)]}) + seamsfixmodeint,2,"","",round(float(scale),1)]}) # Ultimate SD Upscale params: #_, tile_width, tile_height, mask_blur, padding, seams_fix_width, seams_fix_denoise, seams_fix_padding, diff --git a/csvfiles/artmovements.csv b/csvfiles/artmovements.csv index 7436ee5..f3d7f2a 100644 --- a/csvfiles/artmovements.csv +++ b/csvfiles/artmovements.csv @@ -10,6 +10,7 @@ Abstract Illusionism Academism Action Painting Aestheticism +Aetherpunk Afrofuturism Afropunk Altermodern @@ -31,6 +32,7 @@ Ascii Art Ashcan School Atomicpunk Atompunk +Astropunk Auroracore Australian Tonalism Auto-Destructive Art @@ -85,16 +87,19 @@ Cyberpop Cyberpunk Art Dada Art Dark Wave Art +Darksynth Darkcore Darkpunk De Stijl Deathpunk Decopunk Decora +decal art Demoscene Destructive Art Dieselpunk Digital Art +divisionism dmt Dollpunk Doodle Art style @@ -115,6 +120,7 @@ Fashwave Fauvism Feralcore Figurative Art +Flat Art Fluxus Art Folk Art Funk Art @@ -125,6 +131,7 @@ Gamercore Gamerpunk Generative Art Geometric Abstract Art +Geometric Style Glitch Art Glitchcore Gloomcore @@ -133,8 +140,10 @@ Glow In The Dark Glowwave Goblincore Goth Art +Gouache Art Graffiti Street Art Grindhouse +Grimdark Grunge Art Grungepunk Gutai Group @@ -155,12 +164,16 @@ Icepunk Impressionism Industrial Art Islandpunk +Impasto Junglecore Kawaii anime +kalighat Kinetic Pointillism +kinetic art Kingcore Knightcore Land Art +Letterism Libertywave Lightcore Lowbrow Art @@ -170,6 +183,7 @@ Magewave Magical Realism Mannerism Art Margins Art +Medieval art Memecore Art Metalcore Methaphysical painting @@ -181,6 +195,8 @@ Minimalism Art Modern Art Modern European Ink Painting Modernism Art +monotype +mosaic Mushroomcore Mythpunk Naive Art @@ -203,8 +219,10 @@ Nu Goth Art Orientalism Art Orphism Panfuturism +Patachitra Pastel Goth Art Photorealism +Pin-up Pixel Art Pixiecore Pointillism @@ -260,6 +278,8 @@ Synthpunk Synthwave Art Tattoo style Terrorwave +Technopunk +Tenebrism Teslapunk Thriftcore Tinkercore @@ -280,6 +300,7 @@ Voidpunk Vorticism Art Voxel Art Warmcore +Westernpunk Weirdcore Witchcore Wizardcore diff --git a/csvfiles/imagetypes.csv b/csvfiles/imagetypes.csv index 67887f0..78540c0 100644 --- a/csvfiles/imagetypes.csv +++ b/csvfiles/imagetypes.csv @@ -7,10 +7,6 @@ Digital art Painting Drawing Vector Art -Gopro footage -CCTV -Drone photo -Thermal camera Water color painting Oil painting wall Graffiti @@ -34,4 +30,5 @@ Fractal portrait Raw digital photo Airbrush painting -On pale black paper \ No newline at end of file +On pale black paper +Anime \ No newline at end of file diff --git a/csvfiles/materials.csv b/csvfiles/materials.csv index 1d367c2..8a8883c 100644 --- a/csvfiles/materials.csv +++ b/csvfiles/materials.csv @@ -117,4 +117,5 @@ Diamond Garment Galaxy Stars --space- \ No newline at end of file +-space- +Lapidary \ No newline at end of file diff --git a/csvfiles/othertypes.csv b/csvfiles/othertypes.csv index 7a29dbb..1fc4ee4 100644 --- a/csvfiles/othertypes.csv +++ b/csvfiles/othertypes.csv @@ -110,7 +110,6 @@ acrylic marbling art acrylic painting acrylic pour board game -claymation cloisonné Doom engine Quake engine @@ -145,4 +144,117 @@ still life stop motion traditional Haida art traditional Sámi art -x-ray photography \ No newline at end of file +x-ray photography +Gopro footage +CCTV +Drone photo +Thermal camera +50s illustration style +60s illustration style +70s illustration style +80s illustration style +90s illustration style +doll +action figure +action painting art +alcohol ink art +alcohol ink drawing +alebrije art +ASCII art +assemblage art +azulejo texture +bas-relief art +bestiary +black ink art +blacklight palette +brush pen art +caricature art +carving technique +cast paper art +catholic icon +ceramic figurine +charcoal art +chiaroscuro art +child's drawing +cibulak porcelain technique +collagraph technique +color sketchnote drawing +colored pencil drawing +comic book art +comics art +continuous line art +contour drawing +contour rivalry drawing +cross stitch +cross-stitching technique +cutout art +decoupage technique +diagram +doodling drawing +dotted lines art +dribbble style +hieroglyphs +embossing +enamel painting art +encaustic texture +engraving drawing +etching technique +fashion illustration +felt tip pen drawing +fresco art +fused glass art +gilded drawing +gobelin tapestry technique +gold leafing technique +gond painting +graffiti print +graphic print +graphite +hologram +ink wash art +inktober drawing +ivory carving technique +iznik tiles pattern +-culture- vintage poster print +kachina doll +kirigami art +letterpress print +linocut drawing +lithography print +loose sketching drawing +low-poly drawing +marquetry +millefiori +Paint splatter +palette knife art +paper quilling art +papercut art +papier-mache art +patachitra painting +patchwork +pebble art +pen drawing +plasticine +pyrography +quilted art +recycled art +relief art +risograph print +scribble art +sgraffito drawing +silhouette art +silk screen +sloppy strokes drawing +sock puppet +stencil art +stuffed toy +sumi-e outline +swirling line drawing +tilt and drip drawing +tilt and drip painting art +underpainting art +wireframe drawing +woodblock print +woodcut drawing +woodcut technique +zig-zag lines drawing \ No newline at end of file diff --git a/csvfiles/vomit.csv b/csvfiles/vomit.csv index fd351e8..861704e 100644 --- a/csvfiles/vomit.csv +++ b/csvfiles/vomit.csv @@ -54,9 +54,13 @@ full of color geometric patterns glimmering transformation glittering +glitter texture +gilded technique Golden ratio halation +halftone texture hearthstone artwork +icon style Instagram intricate details intricate @@ -74,6 +78,7 @@ matte MOBA style moody Movie concept art +multidimensional National Geographic opulent otherworldly @@ -90,6 +95,8 @@ rich color rpg concept art Rule of Thirds sfumato +sgraffito +sloppy strokes silhouette Simplified style Spirals @@ -101,7 +108,10 @@ Swirling -color- Swirling -material- symbolism taiji +triadic under water +underpainting vibrant vignette +vintage Zentangle \ No newline at end of file diff --git a/csvfiles/waterlocations.csv b/csvfiles/waterlocations.csv index 35f1655..18c64fb 100644 --- a/csvfiles/waterlocations.csv +++ b/csvfiles/waterlocations.csv @@ -27,4 +27,6 @@ Bath Shower Sauna Spa -Thermal baths \ No newline at end of file +Thermal baths +Thermae +-culture- bath \ No newline at end of file diff --git a/main.py b/main.py index 2c60b6a..6ea5cf5 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import random import uuid import re from datetime import datetime +import time sys.path.append(os.path.abspath("..")) from call_txt2img import * @@ -22,9 +23,25 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s filename="" originalsize=size originalmodel = model + originalsamplingmethod = samplingmethod + originalimg2imgmodel = img2imgmodel + originalimg2imgsamplingmethod = img2imgsamplingmethod + originalimg2imgupscaler = img2imgupscaler + + originalupscaler = upscaler + insanitylevel = int(insanitylevel) + originalimg2imgdenoisestrength = img2imgdenoisestrength + originalimg2imgpadding = img2imgpadding + + optionsresponse = requests.get(url=f'{apiurl}/sdapi/v1/options') + optionsresponsejson = optionsresponse.json() + + currentlyselectedmodel = optionsresponsejson["sd_model_checkpoint"] + + if(onlyupscale==True): script_dir = os.path.dirname(os.path.abspath(__file__)) # Script directory inputupscalemefolder = os.path.join(script_dir, "./automated_outputs/upscale_me/" ) @@ -59,6 +76,14 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s while steps < loops: + # load the base model as a workaround + if(steps > 0): + print("to prevent a memory issue, we are going to load base 1.5, and then load the chosen model back in") + option_payload = { + "sd_model_checkpoint": "v1-5-pruned-emaonly.safetensors [6ce0161689]" + } + response = requests.post(url=f'{apiurl}/sdapi/v1/options', json=option_payload) + # build prompt if(silentmode==True and workprompt == ""): print("Trying to use provided workflow prompt, but is empty. Generating a random prompt instead.") @@ -73,12 +98,17 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s randomprompt = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept) # make the filename, from from a to the first comma - start_index = randomprompt.find("of a ") + len("of a ") - # find the index of the first comma after "of a" or end of the prompt - end_index = randomprompt.find(",", start_index) - if(end_index == -1): - end_index=len(randomprompt) + if(randomprompt.find("of a ") != -1): + start_index = randomprompt.find("of a ") + len("of a ") + end_index = randomprompt.find(",", start_index) + if(end_index == -1): + end_index=len(randomprompt) + else: + start_index = 0 + end_index = 128 + + # extract the desired substring using slicing filename = randomprompt[start_index:end_index] @@ -99,6 +129,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s # create a datetime object for the current date and time now = datetime.now() filenamecomplete = now.strftime("%Y%m%d%H%M%S") + "_" + filename.replace(" ", "_").strip() + originalfilenamecomplete = filenamecomplete # prompt + size if(originalsize == "all"): @@ -113,20 +144,22 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s while "inpaint" in model: model = random.choice(modellist) print("Going to run with model " + model) + if(originalmodel=="currently selected model"): + model = currentlyselectedmodel # set the model here - if(originalmodel!="currently selected model"): - option_payload = { - "sd_model_checkpoint": model - } - response = requests.post(url=f'{apiurl}/sdapi/v1/options', json=option_payload) - - if(samplingmethod=="all"): + #if(originalmodel!="currently selected model"): + option_payload = { + "sd_model_checkpoint": model + } + response = requests.post(url=f'{apiurl}/sdapi/v1/options', json=option_payload) + + if(originalsamplingmethod=="all"): samplingmethod = random.choice(samplerlist) print ("Going to run with sampling method " + samplingmethod) - if(upscaler=="all" and hiresfix == True): + if(originalupscaler=="all" and hiresfix == True): upscaler = random.choice(upscalerlist) print ("Going to run with upscaler " + upscaler) @@ -158,12 +191,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s img2imgloops = int(img2imgbatch) if(img2imgactivate == False): # If we dont want to run, turn it off img2imgloops = 0 - img2imgsteps = 0 - - # start the batching! - while img2imgsteps < img2imgloops: - - + else: #Check if there is any random value we have to choose or not if(originalimg2imgmodel=="all"): img2imgmodel = random.choice(modellist) @@ -171,38 +199,60 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s while "inpaint" in model: img2imgmodel = random.choice(modellist) print("Going to upscale with model " + img2imgmodel) + if(originalimg2imgmodel=="currently selected model"): + img2imgmodel = currentlyselectedmodel # set the model here - if(originalimg2imgmodel!="currently selected model"): - option_payload = { - "sd_model_checkpoint": img2imgmodel - } - response = requests.post(url=f'{apiurl}/sdapi/v1/options', json=option_payload) + #if(originalimg2imgmodel!="currently selected model"): + option_payload = { + "sd_model_checkpoint": img2imgmodel + } + response = requests.post(url=f'{apiurl}/sdapi/v1/options', json=option_payload) - if(img2imgsamplingmethod=="all"): + if(originalimg2imgsamplingmethod=="all"): img2imgsamplingmethod = random.choice(img2imgsamplerlist) print ("Going to upscale with sampling method " + img2imgsamplingmethod) - if(img2imgupscaler=="all"): + if(originalimg2imgupscaler=="all"): img2imgupscaler = random.choice(img2imgupscalerlist) print ("Going to run with upscaler " + img2imgupscaler) - + # WebUI fix for PLMS and UniPC and img2img if(img2imgsamplingmethod in ['PLMS', 'UniPC']): # PLMS/UniPC do not support img2img so we just silently switch to DDIM img2imgsamplingmethod = 'DDIM' + img2imgsteps = 0 + + # start the batching! + img2imgdenoisestrength = originalimg2imgdenoisestrength + img2imgpadding = originalimg2imgpadding + + while img2imgsteps < img2imgloops: + print(img2imgdenoisestrength) + print(img2imgpadding) + + print("test for filename issues?") + print(filenamecomplete) + + filenamecomplete = originalfilenamecomplete + "_" + str(img2imgsteps) + print(filenamecomplete) + img2img = call_img2img(image, originalimage, originalpnginfo, apiurl, filenamecomplete, randomprompt,negativeprompt,img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel, img2imgdenoisestrength, img2imgscale, img2imgpadding,upscalescript,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur,controlnetenabled, controlnetmodel,controlnetblockymode) image = img2img[0] if(originalpnginfo==""): originalpnginfo = img2img[1] - img2imgdenoisestrength = str(float(img2imgdenoisestrength) + float(img2imgdenoisestrengthmod)) # lower or increase the denoise strength for each batch - img2imgpadding = int(int(img2imgpadding) * float(img2imgscale)) # also increase padding by scale + img2imgdenoisestrength = str(round(float(img2imgdenoisestrength) + float(img2imgdenoisestrengthmod),2)) # lower or increase the denoise strength for each batch + img2imgpadding = str(int(int(img2imgpadding) * float(img2imgscale))) # also increase padding by scale if(int(img2imgpadding)>256): # but not overdo it :D img2imgpadding="256" + # Sometimes, we are too quick to do another call, causing memory issues. So we wait a bit to let the system settle done a bit. + # Its stupid but it works. Sometimes.... + time.sleep(5) + img2imgsteps += 1 # upscale via extras upscaler next