diff --git a/StylePile.py b/StylePile.py index 0b4c840..fc90c81 100644 --- a/StylePile.py +++ b/StylePile.py @@ -1,572 +1,714 @@ -# A simple helper script for AUTOMATIC1111/stable-diffusion-webui. +# ,, ,, ,, +# .M"""bgd mm `7MM `7MM"""Mq. db `7MM +# ,MI "Y MM MM MM `MM. MM +# `MMb. mmMMmm `7M' `MF'MM .gP"Ya MM ,M9 `7MM MM .gP"Ya +# `YMMNq. MM VA ,V MM ,M' Yb MMmmdM9 MM MM ,M' Yb +# . `MM MM VA ,V MM 8M"""""" MM MM MM 8M"""""" +# Mb dM MM VVV MM YM. , MM MM MM YM. , +# P"Ybmmd" `Mbmo ,V .JMML.`Mbmmd'.JMML. .JMML..JMML.`Mbmmd' +# ,V +# OOb" +# +# A helper script for AUTOMATIC1111/stable-diffusion-webui. # Enter your keywords and let the selections help you determine the look. # https://replicate.com/methexis-inc/img2prompt has been an incredible help for improving the prompts. # https://docs.google.com/document/d/1ZtNwY1PragKITY0F4R-f8CarwHojc9Wrf37d0NONHDg/ has been equally super important. -# Huge thanks to https://github.com/xram64 for helping fix the interface +# Thanks to https://github.com/xram64 for helping fix the interface +# Art movements from https://en.wikipedia.org/wiki/List_of_art_movements I threw out the ones that did not work + +# Portrait prompt - Portrait of an attractive young lady,flower field background, (by artist [X]:1.3), square ratio +# Negative - missing limbs, extra limbs, watermark,label,text -# Portrait prompt - Portrait of an attractive young lady,flower field background, [X], square ratio -# Neagative - missing limbs, extra limbs, watermark,label,text # Landscape prompt - Small house in the middle of a forest,near a lake # Action prompt - Astronaut floating in space,firing laser at alien ship,galaxy background # Negatives - watermark,label,text # 20 steps on Euler A -# Seed - 666 +# Seed - 669 import copy +import os +import random +from os import listdir, path +from os.path import isfile, join import modules.scripts as scripts import gradio as gr +from modules.processing import Processed, process_images +from modules.shared import cmd_opts, opts, state -import os -from os.path import isfile,join -from os import listdir +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> -from os import path -from modules.paths import script_path -from modules.shared import opts,cmd_opts,state +file_dir = os.path.dirname(os.path.realpath("__file__")) +ResourceDir = os.path.join(file_dir, f"scripts/StylePile/") -from modules.processing import process_images,Processed -import random +def FilesInFolder(SourceFolder): + return [file for file in os.listdir(SourceFolder)] -BeforeResultType = { - "Not set":"", - "Photography":"High quality Professional Photo", - "Digital Artwork":"Digital Artwork", - "3D Rendering":"Professional 3D rendering", - "Painting":"Painting", - "Drawing":"Drawing", - "Vector Art":"Vector illustration" + +def FilesInFolderFullPath(SourceFolder): + return [SourceFolder + file for file in os.listdir(SourceFolder)] + + +ResultNames = [ + "Photography", + "Digital Artwork", + "3D Rendering", + "Painting", + "Drawing", + "Vector Art" +] + +ResultTypeBefore = { + "Photography": "High quality Professional Photo", + "Digital Artwork": "Digital Artwork", + "3D Rendering": "Professional 3D rendering", + "Painting": "Painting", + "Drawing": "Drawing", + "Vector Art": "Vector image" } -ResultType = { - "Not set":"", - "Photography":",8K,highly detailed,Sharp,Photo-realism,Professional photograph,Masterpiece", - "Digital Artwork":",highly detailed,featured on CGSociety,trending on ArtStation", - "3D Rendering":",highly detailed,Art by senior Artist,Polycount,trending on CGSociety,trending on ArtStation", - "Painting":"", - "Drawing":"", - "Vector Art":",detailed,Flat style,Illustration,Unsplash,Behance,icons8" +ResultTypePositives = { + "Photography": ",HD,4K,8K,highly detailed,Sharp,Photo-realism,Professional photograph,Masterpiece", + "Digital Artwork": ",Highly Detailed,Featured on CGSociety,Trending on ArtStation", + "3D Rendering": ",Highly detailed,Art by senior Artist,Polycount,trending on CGSociety,trending on ArtStation", + "Painting": " ", + "Drawing": " ", + "Vector Art": ",(Flat style:1.3),Illustration,Behance" } ResultTypeNegatives = { - "Not set":"", - "Photography":",Out of focus,Wedding,Frame,Painting,tumblr", - "Digital Artwork":",3D rendering,Screenshot,Software,UI", - "3D Rendering":",((Wireframe)),Polygons,Screenshot,Software,UI", - "Painting":",((Photography)),(frame)", - "Drawing":",Photography,Artifacts,Table,Paper,Pencils,Pages,Wall", - "Vector Art":",Photography,Artifacts,Table,Paper,Pencils,Pages" + "Photography": ",Amateur,Low rated,Phone,Wedding,Frame,Painting,tumblr", + "Digital Artwork": ",Scribbles,Low quality,Low rated,Mediocre,3D rendering,Screenshot,Software,UI", + "3D Rendering": ",((Wireframe)),Polygons,Screenshot,Character design,Software,UI", + "Painting": "Low quality,Bad composition,Faded,(Photography:1.5),(Frame:1.3)", + "Drawing": ",Low quality,Photography,Artifacts,Table,Paper,Pencils,Pages,Wall", + "Vector Art": ",(Watermark:1.5),(Text:1.3)" } -ResultMood = { - "Not set":"", - "Amusing":" (Amusing:1.33) ", - "Angry":" (Angry:1.33) ", - "Cosy":" (Cosy:1.33) ", - "Depressing":" (Depressing:1.33) ", - "Disgusting":" (Disgusting:1.33) ", - "Embarrassing":" (Embarrassing:1.33) ", - "Energetic":" (Energetic:1.33) ", - "Evil":" (Evil:1.33) ", - "Fearful":" (Fearful:1.33) ", - "Frightening":" (Frightening:1.33) ", - "Grim":" (Grim:1.33) ", - "Guilty":" (Guilty:1.33) ", - "Happy":" (Happy:1.33) ", - "Hopeful":" (Hopeful:1.33) ", - "Hopeless":" (Hopeless:1.33) ", - "Lonely":" (Lonely:1.33) ", - "Lustful":" (Lustful:1.33) ", - "Peaceful":" (Peaceful:1.33) ", - "Proud":" (Proud:1.33) ", - "Relieving":" (Relieving:1.33) ", - "Romantic":" (Romantic:1.33) ", - "Sad":" (Sad:1.33) ", - "Satisfying":" (Satisfying:1.33) ", - "Shameful":" (Shameful:1.33) ", - "Surprising":" (Surprising:1.33) " +ResultType = { + "Not set": "", + "Random": "Random", } -Artists= { - "Not set":"", - "Aboudia":"by Artist Aboudia", - "Adi Granov":"by Artist Adi Granov", - "Akihiko Yoshida":"by Artist Akihiko Yoshida", - "Al Williamson":"by Artist Al Williamson", - "Albert Lynch":"by Artist Albert Lynch", - "Alex Grey":"by Artist Alex Grey", - "Alex Ross":"by Artist Alex Ross", - "Alex Toth":"by Artist Alex Toth", - "Alexander Jansson":"by Artist Alexander Jansson", - "Alphonse Mucha":"by Artist Alphonse Mucha", - "Andrew Loomis":"by Artist Andrew Loomis", - "Artgerm":"by Artist Artgerm", - "Babajide Olatunji":"by Artist Babajide Olatunji", - "Barbara Kruger":"by Artist Barbara Kruger", - "Beeple":"by Artist Beeple", - "Bob Byerley":"by Artist Bob Byerley", - "Bob Eggleton":"by Artist Bob Eggleton", - "Bob Peak":"by Artist Bob Peak", - "Boris Vallejo":"by Artist Boris Vallejo", - "Carmine Infantino":"by Artist Carmine Infantino", - "Caspar David Friedrich":"by Artist Caspar David Friedrich", - "Charlie Bowater":"by Artist Charlie Bowater", - "Chris Foss":"by Artist Chris Foss", - "Clive Barker":"by Artist Clive Barker", - "Coles Phillips":"by Artist Coles Phillips", - "Curt Swan":"by Artist Curt Swan", - "Dan Mumford":"by Artist Dan Mumford", - "Diego Rivera":"by Artist Diego Rivera", - "Donato Giancola":"by Artist Donato Giancola", - "Dorina Costras":"by Artist Dorina Costras", - "Edith Head":"by Artist Edith Head", - "Edmund Dulac":"by Artist Edmund Dulac", - "Edvard Munch":"by Artist Edvard Munch", - "Erin Hanson":"by Artist Erin Hanson", - "Esao Andrews":"by Artist Esao Andrews", - "Esteban Maroto":"by Artist Esteban Maroto", - "Eyvind Earle":"by Artist Eyvind Earle", - "Fujishima Takeji":"by Artist Fujishima Takeji", - "Gediminas Pranckevicius":"by Artist Gediminas Pranckevicius", - "Gene Colan":"by Artist Gene Colan", - "Georgy Kurasov":"by Artist Georgy Kurasov", - "Gil Elvgren":"by Artist Gil Elvgren", - "Gil Kane":"by Artist Gil Kane", - "Greg Manchess":"by Artist Greg Manchess", - "Greg Rutkowski":"by Artist Greg Rutkowski", - "Gustave Doré":"by Artist Gustave Doré", - "H.P. Lovecraft":"by Artist H.P. Lovecraft", - "H.R. Giger":"by Artist H.R. Giger", - "Henry Clive":"by Artist Henry Clive", - "Hiroshi Nagai":"by Artist Hiroshi Nagai", - "Hsiao-Ron Cheng":"by Artist Hsiao-Ron Cheng", - "Huang Guangjian":"by Artist Huang Guangjian", - "Ilya Kuvshinov":"by Artist Ilya Kuvshinov", - "J.C. Leyendecker":"by Artist J.C. Leyendecker", - "Jack Kirby":"by Artist Jack Kirby", - "Jackson Pollock":"by Artist Jackson Pollock", - "James Gilleard":"by Artist James Gilleard", - "James Gurney":"by Artist James Gurney", - "James Jean":"by Artist James Jean", - "Jason Chan":"by Artist Jason Chan", - "Jason Edmiston":"by Artist Jason Edmiston", - "Jeremy Lipking":"by Artist Jeremy Lipking", - "Jian Chong Min":"by Artist Jian Chong Min", - "Jim Burns":"by Artist Jim Burns", - "Joao Ruas":"by Artist Joao Ruas", - "Joe Kubert":"by Artist Joe Kubert", - "John Romita Jr":"by Artist John Romita Jr", - "Joseph Leyendecker":"by Artist Joseph Leyendecker", - "Junji Ito":"by Artist Junji Ito", - "Kadir Nelson":"by Artist Kadir Nelson", - "Kawase Hasui":"by Artist Kawase Hasui", - "Kehinde Wiley":"by Artist Kehinde Wiley", - "Koho Shoda":"by Artist Koho Shoda", - "Krenz CushArt":"by Artist Krenz CushArt", - "Leonid Afremov":"by Artist Leonid Afremov", - "Lisa Frank":"by Artist Lisa Frank", - "Loish":"by Artist Loish", - "M.C. Escher":"by Artist M.C. Escher", - "Madhvi Parekh":"by Artist Madhvi Parekh", - "Makoto Shinkai":"by Artist Makoto Shinkai", - "Marc Chagall":"by Artist Marc Chagall", - "Marc Simonetti":"by Artist Marc Simonetti", - "Masamune Shirow":"by Artist Masamune Shirow", - "Miho Hirano":"by Artist Miho Hirano", - "Mort Kunstler":"by Artist Mort Kunstler", - "Njideka Akunyili Crosby":"by Artist Njideka Akunyili Crosby", - "Norman Rockwell":"by Artist Norman Rockwell", - "Pang Xunqin":"by Artist Pang Xunqin", - "Paul Signac":"by Artist Paul Signac", - "Peter Elson":"by Artist Peter Elson", - "Peter Mohrbacher":"by Artist Peter Mohrbacher", - "Phil Noto":"by Artist Phil Noto", - "Raymond Swanland":"by Artist Raymond Swanland", - "Rene Magritte":"by Artist Rene Magritte", - "Rhads":"by Artist Rhads", - "Richard Corben":"by Artist Richard Corben", - "Rob Gonsalves":"by Artist Rob Gonsalves", - "Robert McCall":"by Artist Robert McCall", - "Romero Britto":"by Artist Romero Britto", - "RossDraws":"by Artist RossDraws", - "Ruan Jia":"by Artist Ruan Jia", - "Ryan Pancoast":"by Artist Ryan Pancoast", - "Sachin Teng":"by Artist Sachin Teng", - "Salvador Dali":"by Artist Salvador Dali", - "Sam Gilliam":"by Artist Sam Gilliam", - "Scott Listfield":"by Artist Scott Listfield", - "Shane Turner":"by Artist Shane Turner", - "Simon Stalenhag":"by Artist Simon Stalenhag", - "Stephan Martinière":"by Artist Stephan Martinière", - "Steve Ditko":"by Artist Steve Ditko", - "Syd Mead":"by Artist Syd Mead", - "Takashi Murakami":"by Artist Takashi Murakami", - "Tara McPherson":"by Artist Tara McPherson", - "Tarsila do Amaral":"by Artist Tarsila do Amaral", - "Ted Nasmith":"by Artist Ted Nasmith", - "Thomas Blackshear":"by Artist Thomas Blackshear", - "Thomas Kinkade":"by Artist Thomas Kinkade", - "Tom Bagshaw":"by Artist Tom Bagshaw", - "Tom Lovell":"by Artist Tom Lovell", - "Tomasz Alen":"by Artist Tomasz Alen", - "Toshi Yoshida":"by Artist Toshi Yoshida", - "Trina Robbins":"by Artist Trina Robbins", - "Tsutomu Nihei":"by Artist Tsutomu Nihei", - "Victo Ngai":"by Artist Victo Ngai", - "Vincent DiFate":"by Artist Vincent DiFate", - "Wadim Kashin":"by Artist Wadim Kashin", - "Walter Crane":"by Artist Walter Crane", - "Wangechi Mutu":"by Artist Wangechi Mutu", - "Wayne Barlowe":"by Artist Wayne Barlowe", - "Will Barnet":"by Artist Will Barnet", - "William Dodge":"by Artist William Dodge", - "WLOP":"by Artist WLOP", - "Yayoi Kusama":"by Artist Yayoi Kusama", - "Yoji Shinkawa":"by Artist Yoji Shinkawa", - "Yoshitaka Amano":"by Artist Yoshitaka Amano" -} +ResultType.update(ResultTypePositives) -ResultStyle = { - "Not set":"", - "Abstract ":"Abstract Art", - "Acidwave":"Acidwave Artwork", - "Acrylic":"Acrylic", - "Aestheticism ":"Aestheticism Art", - "Anime":"Pixiv,Anime", - "Art Deco":"Art Deco Painting", - "Nouveau":"Art Nouveau", - "Ashcan School Style":"Ashcan School Style", - "Avant-garde":"Avant-garde Painting", - "Ballpoint Pen":"Ballpoint Pen Artwork", - "Baroque":"Baroque Painting", - "Classicism":"Classicism", - "CoBrA":"CoBrA Painting", - "Colored Pencil":"Colored Pencil Drawing", - "Constructivism":"Constructivism Painting", - "Cubism":"Cubism", - "Dreamcore ":"Dreamcore Art", - "Drip":"Drip Painting", - "Encaustic":"Encaustic Painting", - "Expressionism":"Expressionism", - "Fauvism":"Fauvism", - "Finger Painting":"Finger Painting", - "Futurism":"Futurism Painting", - "Gothic":"Gothic Painting", - "Gouache":"Gouache", - "Hot Wax":"Hot Wax Painting", - "Impressionism":"Impressionism", - "Ink Wash":"Ink Wash", - "Japanese":"Japanese Artwork", - "Korean":"Korean Painting", - "Line Art":"Line Art Drawing", - "Linocut":"Linocut", - "Lowpoly":"Lowpoly", - "Manga":"Manga Painting", - "Marker":"Marker Painting", - "Modern Comics":"Marvel Comics Art,DC Comics Art,Image comics Art,Dark Horse Comics Art", - "Mural":"Mural Painting", - "Neoclassicism":"Neoclassicism", - "Oil Painting":"Oil Painting Style", - "Pastel":"Pastel Painting", - "Pencil ":"Pencil Art", - "Photorealism ":"Photorealism Art", - "Pixel Art":"Atari graphics 16-bit Pixel Art", - "Pop Art":"Pop Art", - "Pop Surrealism":"Pop Surrealism", - "Psychedelic ":"Psychedelic Art", - "Realism":"Realism", - "Renaissance":"Renaissance", - "Rococo":"Rococo Painting", - "Sprite Artwork":"Low resolution Sprite Art", - "Street Art":"Street Art Painting", - "Suprematism":"Suprematism", - "Vaporwave":"Vaporwave digital Painting", - "Vintage Comics":"Vintage Comic Art", - "Watercolor":"Watercolor Painting", +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + +ResultDirectionList = FilesInFolder(ResourceDir + "Directions/") +ResultDirectionList = list( + map(lambda x: x.replace(".jpg", ""), ResultDirectionList)) +ResultDirection = ["Not set", "Random"] + ResultDirectionList + +ResultDirectionImages = FilesInFolderFullPath(ResourceDir + "Directions/") +ResultDirectionImages = list( + map(lambda x: x.replace("\\", "/"), ResultDirectionImages)) + +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + +ResultMoodList = FilesInFolder(ResourceDir + "Moods/") +ResultMoodList = list(map(lambda x: x.replace(".jpg", ""), ResultMoodList)) +ResultMood = ["Not set", "Random"] + ResultMoodList + +ResultMoodImages = FilesInFolderFullPath(ResourceDir + "Moods/") +ResultMoodImages = list(map(lambda x: x.replace("\\", "/"), ResultMoodImages)) + +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + +ResultArtistList = FilesInFolder(ResourceDir + "Artists/") +ResultArtistList = list(map(lambda x: x.replace(".jpg", ""), ResultArtistList)) +Artists = ["Not set", "Random"] + ResultArtistList + +ResultArtistImages = FilesInFolderFullPath(ResourceDir + "Artists/") +ResultArtistImages = list( + map(lambda x: x.replace("\\", "/"), ResultArtistImages)) + +#ResultArtistColumn = "\n".join(str(item) for item in ResultArtistList) + +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + +ArtMovementList = FilesInFolder(ResourceDir + "Art Movements/") +ArtMovementList = list(map(lambda x: x.replace(".jpg", ""), ArtMovementList)) +ArtMovements = ["Not set", "Random"] + ArtMovementList + +ArtMovementImages = FilesInFolderFullPath(ResourceDir + "Art Movements/") +ArtMovementImages = list( + map(lambda x: x.replace("\\", "/"), ArtMovementImages)) + +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + +ResultColorList = { + "Not set": "", + "Primary Colors": ",((primary Colors))", + "Vivid": ",((vivid Colors)),((vibrant)),((colorful))", + "Pastel Colors": ",((pastel Colors))", + "Muted Colors": ",((muted Colors))", + "Grayscale": ",((grayscale))", + "Black and white": ",((black and white))", + "Infrared": ",((infrared))", + "Technicolor": ",((Technicolor))", + "Kinemacolor": ",((Kinemacolor))", + "Kodachrome": ",((Kodachrome))", + "Cinecolor": ",((Cinecolor))", + "Agfacolor": ",((Agfacolor))", + "Velvia": ",((Velvia))", + "Provia": ",((Provia))", + "Fujifilm Superia": ",((Fujifilm Superia))", + "Kodak Ektar": ",((Kodak Ektar))", + "Kodak Portra": ",((Kodak Portra))", + "High Contrast": ",((High Contrast))", + "Low Contrast": ",((Low Contrast))" } ResultColors = { - "Not set":"", - "Primary Colors":",((primary Colors))", - "Vivid":",((vivid Colors)),((vibrant)),((colorful))", - "Pastel Colors":",((pastel Colors))", - "Muted Colors":",((muted Colors))", - "Grayscale":",((grayscale))", - "Black and white":",((black and white))", - "Infrared":",((infrared))" + "Not set": "", + "Random": "Random", } -ImageView = { - "Not set":"", - "Symmetrical":",Symmetrical", - "Tilt-shift":",Tilt-shift lens", - "Long shot angle":",Long shot angle", - "Medium shot angle":",Medium shot angle", - "Wide shot angle":",Wide shot angle", - "Portrait":",(portrait),50mm,bokeh", - "Extreme close-up angle":",Extreme close-up angle", - "Macro":",Macro", - "Microscopic":",Microscopic", - "Isometric":",Isometric", - "Panorama":",Panorama,360", - "Fisheye lens":",Fisheye lens", - "Overhead-angle":",Overhead-angle", - "Birds eye view":",Shot from a birds eye camera angle" -} +ResultColors.update(ResultColorList) + +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + +TipsAndTricks = [ + "Be specific. Add details in sequence, separated by commas. Like 'Cute black kitten, yellow eyes' + selecting Photography as image type, will get you to the result you want faster than just 'black kitten'.", + "Try out random values. For example, set artist to random, crank up the batch count and enjoy the show. Mix and match random settings.", + "If you add your own artist, I would recommend having 'by Artist' in front of their name. Depending on their popularity (or lack thereof) this appears to have a very tangible influence on the result.", + "Mix and match artists from the dropdowns (or type your own) for some interesting results. Having one artist selected and other(s) set to random is also a nice way to find new looks with some amount of predictability.", + "Parenthesis can be added to make parts of the prompt stronger. So ((cute kitten)) will make it extra cute (try it out). This is also important if a style is affecting your original prompt too much. Make that prompt stronger by adding parenthesis around it, like this: ((promt)). A strength modifier value can also be used, like this (prompt:1.1).", + "Prompts can be split like [A|B] to sequentially use terms, one after another on each step. For example **[cat|dog]** will produce a hybrid catdog.", + "Using **[A:B:0.4]** will switch to other terms after the first one has been active for a certain percentage of steps. So [cat:dog:0.4] will build a cat 40% of the time and then start turning it into a dog. Usually this needs more steps to work properly.", + "During long cold winter nights, you can turn your PC into a heater by generating hundreds of images non-stop.", + "Feel free to share feedback and ideas on github: https://github.com/some9000/StylePile", + "Some things work together, others don't. Like Photography doesn't work too great with many Art movements or Drawing will not become photorealistic just because that was selected." +] + +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> FocusOn = { - "No focus":"", + "No focus": "", - "Portraits":",(close portrait:1.6),thematic background", - "Feminine portrait":",(close portrait:1.6),(Feminine:1.6),(beautiful:1.7),(attractive:1.6),handsome,calendar pose,perfectly detailed eyes,studio lighting,thematic background", - "Masculine portrait":",(close portrait:1.6),(Masculine:1.4),attractive,handsome,calendar pose,perfectly detailed eyes,studio lighting,thematic background", + "Portraits": ",(close portrait:1.6),thematic background", + "Feminine portrait": ",(close portrait:1.6),(Feminine:1.6),(beautiful:1.7),(attractive:1.6),handsome,calendar pose,perfectly detailed eyes,studio lighting,thematic background", + "Masculine portrait": ",(close portrait:1.6),(Masculine:1.4),attractive,handsome,calendar pose,perfectly detailed eyes,studio lighting,thematic background", - "WaiFusion":",close portrait,(manga:1.3),beautiful,attractive,handsome,trending on ArtStation,DeviantArt contest winner,CGSociety,ultrafine,detailed,studio lighting", + "WaiFusion": ",close portrait,(manga:1.3),beautiful,attractive,handsome,trending on ArtStation,DeviantArt contest winner,CGSociety,ultrafine,detailed,studio lighting", - "Horrible Monsters":",monster,ugly,surgery,evisceration,morbid,cut,open,rotten,mutilated,deformed,disfigured,malformed,missing limbs,extra limbs,bloody,slimy,goo,Richard Estes,Audrey Flack,Ralph Goings,Robert Bechtle,Tomasz Alen Kopera,H.R.Giger,Joel Boucquemont,ArtStation,DeviantArt contest winner,thematic background", + "Horrible Monsters": ",monster,ugly,surgery,evisceration,morbid,cut,open,rotten,mutilated,deformed,disfigured,malformed,missing limbs,extra limbs,bloody,slimy,goo,Richard Estes,Audrey Flack,Ralph Goings,Robert Bechtle,Tomasz Alen Kopera,H.R.Giger,Joel Boucquemont,ArtStation,DeviantArt contest winner,thematic background", - "Robots":",robot,((cyborg)),machine,futuristic,concept Art by senior character Artist,featured on zbrush central,trending on polycount,trending on ArtStation,CGSociety,hard surface modeling", - - "Retrofuturism":",((retrofuturism)),(science fiction),dystopian Art,ultrafine,detailed,future tech,by Clarence Holbrook CArter,by Ed Emshwiller,CGSociety,ArtStation contest winner,trending on ArtStation,DeviantArt contest winner,Fallout", + "Robots": ",robot,((cyborg)),machine,futuristic,concept Art by senior character Artist,featured on zbrush central,trending on polycount,trending on ArtStation,CGSociety,hard surface modeling", - "Propaganda":",propaganda poster,soviet poster,sovietwave", + "Retrofuturism": ",((retrofuturism)),(science fiction),dystopian Art,ultrafine,detailed,future tech,by Clarence Holbrook CArter,by Ed Emshwiller,CGSociety,ArtStation contest winner,trending on ArtStation,DeviantArt contest winner,Fallout", - "Landscapes":",naturalism,land Art,regionalism,shutterstock contest winner,trending on unsplash,featured on Flickr" + "Propaganda": ",propaganda poster,soviet poster,sovietwave", + + "Landscapes": ",naturalism,land Art,regionalism,shutterstock contest winner,trending on unsplash,featured on Flickr" } FocusOnNegatives = { - "No focus":"", + "No focus": "", - "Portraits":",distorted pupils,distorted eyes,Unnatural anatomy,strange anatomy,things on face", - "Feminine portrait":",distorted pupils,distorted eyes,Unnatural anatomy,strange anatomy,things on face", - "Masculine portrait":",distorted pupils,distorted eyes,Unnatural anatomy,strange anatomy,things on face", + "Portraits": ",distorted pupils,distorted eyes,Unnatural anatomy,strange anatomy,things on face", + "Feminine portrait": ",distorted pupils,distorted eyes,Unnatural anatomy,strange anatomy,things on face", + "Masculine portrait": ",distorted pupils,distorted eyes,Unnatural anatomy,strange anatomy,things on face", - "WaiFusion":" things on face,Unnatural anatomy,strange anatomy", + "WaiFusion": " things on face,Unnatural anatomy,strange anatomy", - "Horrible Monsters":",(attractive),pretty,smooth,cArtoon,pixar,human", + "Horrible Monsters": ",(attractive),pretty,smooth,cArtoon,pixar,human", - "Robots":",cArtoon", - - "Retrofuturism":",extra limbs,malformed limbs,modern", + "Robots": ",cArtoon", - "Propaganda":",extra limbs,malformed limbs,modern", + "Retrofuturism": ",extra limbs,malformed limbs,modern", - "Landscapes":"((hdr)),((terragen)),((rendering)),(high contrast)" + "Propaganda": ",extra limbs,malformed limbs,modern", + + "Landscapes": "((hdr)),((terragen)),((rendering)),(high contrast)" } +# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + # At some point in time it looked like adding a bunch of these negative prompts helps,but now I am not so sure... # AlwaysBad = ",((watermark)),(text),(overlays),getty images,(cropped),low quality,worst quality" -AlwaysBad = ",((watermark)),(text),(overlays),signature" +AlwaysBad = ",(text),(overlays),signature" + class Script(scripts.Script): + def title(self): return "StylePile" - def ui(self,is_img2img,title="StylePile"): - file_dir = os.path.dirname(os.path.realpath("__file__")) - ResourceDir = os.path.join(file_dir,f"scripts/StylePile/") + def show(self, is_img2img): + return True - with gr.Column(): + def ui(self, is_img2img): + with gr.Tab("Parameters"): with gr.Row(): with gr.Column(): - cbChangeCount = gr.Checkbox(value=True,label="Set Batch count to Sequential prompt count") - strSequentialPrompt = gr.Textbox(lines=5,label="Sequential prompts [X]",placeholder="Insert [X] anywhere in main prompt to sequentially insert values from here.") - strRandomPrompt = gr.Textbox(lines=5,label="Random prompts [R]",placeholder="Insert [R] anywhere in main prompt to randomly insert values from here.") + ddCoreResultType = gr.Dropdown( + list(ResultType.keys()), label="Image type", value="Not set") + slResultTypeStrength = gr.Slider( + 0, 2, value=1.3, step=0.05, show_label=False) with gr.Column(): - slResultTypeStrength = gr.Slider(0,2,value=2.0,step=0.1,label="Image type strength") - ddResultType = gr.Dropdown(list(ResultType.keys()),label="Image type",value="Not set") - ddResultMood = gr.Dropdown(list(ResultMood.keys()),label="Mood",value="Not set") - ddResultColors = gr.Dropdown(list(ResultColors.keys()),label="Colors",value="Not set") - ddResultView = gr.Dropdown(list(ImageView.keys()),label="View",value="Not set") - ddFocusOn = gr.Dropdown(list(FocusOn.keys()),label = "Focus on (unfinished)",value="No focus") + ddResultDirection = gr.Dropdown( + ResultDirection, label="Direction", value="Not set") + slResultDirectionStrength = gr.Slider( + 0, 2, value=1.3, step=0.05, show_label=False) + with gr.Column(): + ddResultMood = gr.Dropdown( + ResultMood, label="Mood", value="Not set") + slResultMoodStrength = gr.Slider( + 0, 2, value=1.3, step=0.05, show_label=False) + with gr.Column(): + ddResultColors = gr.Dropdown( + list(ResultColors.keys()), label="Colors", value="Not set") + with gr.Column(): + cbChangeCount = gr.Checkbox( + value=True, label="Batch count = Sequence count") + with gr.Column(): + cbShowTips = gr.Checkbox( + value=False, label="Show tips when generating") + + # with gr.Row(): + #ddFocusOn = gr.Dropdown(list(FocusOn.keys()),label = "Focus on (unfinished)",value="No focus") + + with gr.Row(): + strSequentialPrompt = gr.Textbox( + lines=3, label="Sequential prompts [X]", placeholder="Insert [X] anywhere in main prompt to sequentially insert values from here. Random values will be added here or to main prompt.") + with gr.Row(): + strSubSequentialPrompt = gr.Textbox( + lines=3, label="SubSequential prompts [Y]", placeholder="Insert [Y] in the final prompt <== to sequentially insert values from here (and increase prompt count). This is done after all other prompts and loops through all lines.") + + with gr.Row(): + strRandomPromptA = gr.Textbox( + lines=3, label="Random [A]", placeholder="Insert [A] anywhere in main prompt (or [X] prompt) to randomly insert values from here.") + strRandomPromptB = gr.Textbox( + lines=3, label="Random [B]", placeholder="Insert [B] anywhere in main prompt (or [X] prompt) to randomly insert values from here.") + strRandomPromptC = gr.Textbox( + lines=3, label="Random [C]", placeholder="Insert [C] anywhere in main prompt (or [X] prompt) to randomly insert values from here.") + with gr.Row(): with gr.Column(): - sliImageStyleStrength = gr.Slider(0,2,value=1.3,step=0.1,label="Visual style strength") - selResultStyle = gr.Dropdown(list(ResultStyle.keys()),label="Visual style",value="Not set") + selArtistA = gr.Dropdown(Artists, label="Artist", value="Not set") + sliImageArtistStrengthA = gr.Slider(0, 2, value=1.3, step=0.05, label="Influence") + selArtistB = gr.Dropdown(Artists, label="Artist", value="Not set") + sliImageArtistStrengthB = gr.Slider(0, 2, value=1.3, step=0.05, label="Influence") + selArtistC = gr.Dropdown(Artists, label="Artist", value="Not set") + sliImageArtistStrengthC = gr.Slider(0, 2, value=1.3, step=0.05, label="Influence") with gr.Column(): - sliImageArtistStrength = gr.Slider(0,2,value=1.3,step=0.1,label="Artist influence") - selArtist = gr.Dropdown(list(Artists.keys()),label="Artist",value="Not set") + selArtMovementA = gr.Dropdown(ArtMovements, label="Art movement", value="Not set") + selArtMovementStrengthA = gr.Slider(0, 2, value=1.3, step=0.05, label="Influence") + selArtMovementB = gr.Dropdown(ArtMovements, label="Art movement", value="Not set") + selArtMovementStrengthB = gr.Slider(0, 2, value=1.3, step=0.05, label="Influence") + selArtMovementC = gr.Dropdown(ArtMovements, label="Art movement", value="Not set") + selArtMovementStrengthC = gr.Slider(0, 2, value=1.3, step=0.05, label="Influence") - with gr.Accordion(label="Examples, Help and Tips",open=False): - with gr.Tab("Style examples") as StyleTab: - imVisualStyleHint = gr.Image(show_label=False,interactive=False,value=path.join(ResourceDir,"Styles.png")) + with gr.Tab("Directions") as StyleTab: + gr.Gallery(value=ResultDirectionImages, show_label=False).style( + grid=(3, 3, 3, 3, 4, 4), container=False) - with gr.Tab("Artist examples") as ArtistTab: - imArtistHint = gr.Image(show_label=False,interactive=False,value=path.join(ResourceDir,"Artists.png")) + with gr.Tab("Moods"): + gr.Gallery(value=ResultMoodImages, show_label=False).style( + grid=(3, 3, 3, 3, 4, 4), container=False) - with gr.Tab("Mood examples") as MoodTab: - imArtistHint = gr.Image(show_label=False,interactive=False,value=path.join(ResourceDir,"Mood.png")) + with gr.Tab("Artists"): + gr.Gallery(value=ResultArtistImages, show_label=False).style( + grid=(2, 2, 2, 2, 3, 3), container=False) + + with gr.Tab("Art movements"): + gr.Gallery(value=ArtMovementImages, show_label=False).style( + grid=(3, 3, 3, 3, 4, 4), container=False) - with gr.Tab("Help") as HelpTab: - mdHelpText = gr.Markdown( + with gr.Tab("Info") as HelpTab: + gr.Markdown( """ - ## Hello, StylePile here - ### Introduction - **StylePile** is a mix and match system for adding elements to prompts that affect the style of the result. Hence the name. By default, these elements are placed in a specific order and given strength values. Which means the result sort-of evolves. I have generated thousands of images for each main **Image type** and tweaked the keywords to attempt giving expected results most of the time. Certainly, your suggestions for improvements are very welcome. - ### Base workflow - For example, if you select the **Painting** image type, then almost all results will look like Paintings. Selecting **Mood** will have a certain influence on the overall look in some way (if it's something humanoid it may show emotion, but also colors and overall feel may change). Setting **Colors** will change the general tonality of the result. And setting **View** will attempt to change how the subject is viewed. Attempt, because view appears to be the least reliable keyword. These elements are placed in order of influence and supported by certain strength values. These basic settings produce very quick results close to the general look you want. + ### Example images, adding your own + Example images stored in the script folders are more than just images. Their filenames are used to create the Artist, Direction and Mood dropdown selections. This gives you the ability to Add/Remove these parameters as you wish. Just place an image in the folder and name it as the option you want to see in the dropdown. Delete a file to remove that option. + + In case you would like to suggest an artist be added to the roster, I would recommend making 8+ sample images first. To see if SD actually "knows" that artist and their style appears unique enough. The portraits you can see in the info pages were generated with the following settings: + + ### Sample portrait prompt + Positive: Portrait of an attractive young lady,flower field background,(by [X]:1.3), square ratio + Negative - missing limbs, extra limbs, watermark,label,text - Moving on, adding a **Visual style** will combine with **Image type** to influence how the result generally looks. These styles are based on classic and modern Painting/Art/design movements (which I picked after hours and thousands of samples of testing) and can have a strong influence on the end result. Either it will be more realistic or artistic, or look like a comic book etc. In general, this is a really strong element for getting the look you want. Its influence can be adjusted with the slider above. Experiment with the values, keeping in mind that anything above 1.5 will start becoming a mess. In a similar way, but more focused, you can select an **Artist** and, of course, that will have a very visible effect on the result as well. Currently there are 135 artists, 55 art styles and 25 emotions available for selection and represented with preview images. + [X] is **Artist Name Surname** From my research adding **Artist** can really help to get the correct look. - Strength of these settings has been preset at 1.3, as that appears to be the golden ratio for getting good results. Sometimes very low settings have an interesting result as well. You can, and should, freely mix and match these settings to get different results. Classic Painting styles affected or affecting 3D look quite interesting. Photography can look cool with some of the brighter, more artistic styles etc. Sometimes raising CFG scale to 15,20 or more also helps to REALLY push the style onto the image. + 20 steps on Euler A + Seed - 669 - batch of 4 images - ### Advanced workflow - StylePile can overtake the generation process, allowing you to generate a large amount of different results with very little extra work. There are two types of variables you can use: [X] and [R]. When you add an [X] to your prompt, it sequentially takes values from the **Sequential prompts** text area. You can have dozens of lines there and they will be processed in sequence. When you add [R] to the prompt a value from the **Random prompts** text area will be inserted in its place. By combining these a huge variety in prompts is very easy to do. + Generally that produces a fairly nice portrait with enough room to show off the given style. Do compare the results to the actual style. As SD will produce something it 'thinks' may be correct based on their name (guessing nationality, basing it on something that has mentioned a similar name etc) and that influences the results, but not in a good way. + """) + + #with gr.Tab("Values"): + # with gr.Row(): + # gr.Markdown("""Here you can copy all the available Directions, Moods, Artists or Styles in case you want to try out all the possible values. Just copy and paste into the X or Y fields, insert [X] or [Y] into your main prompt and enjoy the show.""") + # with gr.Row(): + # gr.Textbox(label="Direction", value="Insert [X] anywhere in main prompt to sequentially insert values from here. Random values will be added here or to main prompt.") + # gr.Textbox(label="Mood", value="Hmmm") + # gr.Textbox(label="Artists", value=ResultArtistColumn) + # gr.Textbox(label="Styles", value="\n".join(str(item) for item in ArtMovementList)) + + with gr.Tab("Help"): + gr.Markdown( + """ + ## Hello, StylePile here + ### Introduction + **StylePile** is a mix and match system for adding elements to prompts that affect the style of the result. Hence the name. By default, these elements are placed in a specific order and given strength values. Which means the result sort-of evolves. I have generated thousands of images for each main **Image type** and tweaked the keywords to attempt giving expected results most of the time. Certainly, your suggestions for improvements are very welcome. + ### Base workflow + You select extra settings in this script and then hit the standard orange **Generate** button to get results. + + For example, if you select the **Painting** image type, then almost all results will look like Paintings. Selecting **Mood** will have a certain influence on the overall look in some way (if it's something humanoid it may show emotion, but also colors and overall feel may change). Setting **Colors** will change the general tonality of the result. And setting **View** will attempt to change how the subject is viewed. Attempt, because view appears to be the least reliable keyword. These elements are placed in order of influence and supported by certain strength values. These basic settings produce very quick results close to the general look you want. + ![]({path.join(ResourceDir,"Artists.jpg") ''}) + Moving on, adding a **Art movement** will combine with **Image type** to influence how the result generally looks. These styles are based on classic and modern Painting/Art/design movements (which I picked after hours and thousands of samples of testing) and can have a strong influence on the end result. Either it will be more realistic or artistic, or look like a comic book etc. In general, this is a really strong element for getting the look you want. Its influence can be adjusted with the slider above. Experiment with the values, keeping in mind that anything above 1.5 will start becoming a mess. In a similar way, but more focused, you can select an **Artist** and, of course, that will have a very visible effect on the result as well. Currently there are 135 artists, 55 art styles and 25 emotions available for selection and represented with preview images. - When using this, **Batch count** will move through the prompts and **Batch size** will set how many copies with the given prompt to make. If the seed is not random, it will increase with each batch size step. Any random elements will still be picked randomly. + Strength of these settings has been preset at 1.3, as that appears to be the golden ratio for getting good results. Sometimes very low settings have an interesting result as well. You can, and should, freely mix and match these settings to get different results. Classic Painting styles affected or affecting 3D look quite interesting. Photography can look cool with some of the brighter, more artistic styles etc. Sometimes raising CFG scale to 15,20 or more also helps to REALLY push the style onto the image. - ### Tips and tricks - If you add your own Artist, I would recommend having "by Artist" in front of their name. Depending on Artist's popularity (or lack thereof) this appears to have a very tangible influence on the result. + ### Advanced workflow + StylePile can overtake the generation process, allowing you to generate a large amount of different results with very little extra work. There are two types of variables you can use: [X] and [R]. When you add an [X] to your prompt, it sequentially takes values from the **Sequential prompts** text area. You can have dozens of lines there and they will be processed in sequence. When you add [R] to the prompt a value from the **Random** text area will be inserted in its place. By combining these a huge variety in prompts is very easy to do. - Parenthesis can be added to make pArts of the prompt stronger. So **((cute kitten))** will make it extra cute (try it out). This is also important if a style is affecting your original prompt too much. Make that prompt stronger by adding parenthesis around it, like this: **((promt))**. A strength modifier value can also be used, like this **(prompt:1.1)**. To save some typing you can select the line you want to make stronger and use **Ctrl+Shift+Arrow keys up** or **down** to add these parenthesis and change the value. As you can see by default values on most sliders, 1.3 seems like a good stArting point if you want to see some impact. + When using this, **Batch count** will move through the prompts and **Batch size** will set how many copies with the given prompt to make. If the seed is not random, it will increase with each batch size step. Any random elements will still be picked randomly. - Prompts can be split like **[A|B]** to sequentially use terms, one after another on each step. For example **[cat|dog]** will produce a hybrid catdog. + ### Tips and tricks + If you add your own Artist, I would recommend having "by Artist" in front of their name. Depending on their popularity (or lack thereof) this appears to have a very tangible influence on the result. - Using **[A:B:0.4]** will switch to other terms after the first one has been active for a certain percentage of steps. So **[cat:dog:0.4]** will build a cat 40% of the time and then stArt turning it into a dog. Usually this needs more steps to work properly. + Parenthesis can be added to make parts of the prompt stronger. So **((cute kitten))** will make it extra cute (try it out). This is also important if a style is affecting your original prompt too much. Make that prompt stronger by adding parenthesis around it, like this: **((promt))**. A strength modifier value can also be used, like this **(prompt:1.1)**. To save some typing you can select the line you want to make stronger and use **Ctrl+Shift+Arrow keys up** or **down** to add these parenthesis and change the value. As you can see by default values on most sliders, 1.3 seems like a good stArting point if you want to see some impact. - ### In conclusion - I made this because manually changing keywords, looking up possible styles, etc was a pain. It is meant as a fun tool to explore possibilities and make learning Stable Diffusion easier. If you have some ideas or, better yet, would like to contribute in some way*, just visit https://github.com/some9000/StylePile - *Hey, if you have a 12Gb graphics card just laying around I'm happy to take it (: - """) - + Prompts can be split like **[A|B]** to sequentially use terms, one after another on each step. For example **[cat|dog]** will produce a hybrid catdog. + + Using **[A:B:0.4]** will switch to other terms after the first one has been active for a certain percentage of steps. So **[cat:robot:0.4]** will build a cat 40% of the time and then start turning it into a robot. Usually this needs more steps to work properly. + + ### In conclusion + I made this because manually changing keywords, looking up possible styles, etc was a pain. It is meant as a fun tool to explore possibilities and make learning Stable Diffusion easier. If you have some ideas or, better yet, would like to contribute in some way*, just visit https://github.com/some9000/StylePile + *Hey, if you have a 12Gb graphics card just laying around I'm happy to take it (: + """) return [cbChangeCount, - strSequentialPrompt, - strRandomPrompt, - slResultTypeStrength, - ddResultType, - ddResultMood, - ddResultColors, - ddResultView, - ddFocusOn, - sliImageStyleStrength, - selResultStyle, - sliImageArtistStrength, - selArtist, - ] + strSequentialPrompt, + strSubSequentialPrompt, + strRandomPromptA, + strRandomPromptB, + strRandomPromptC, + slResultTypeStrength, + ddCoreResultType, + ddResultDirection, + slResultDirectionStrength, + ddResultMood, + slResultMoodStrength, + ddResultColors, + selArtMovementStrengthA, + selArtMovementA, + selArtMovementStrengthB, + selArtMovementB, + selArtMovementStrengthC, + selArtMovementC, + sliImageArtistStrengthA, + selArtistA, + sliImageArtistStrengthB, + selArtistB, + sliImageArtistStrengthC, + selArtistC, + cbShowTips + ] + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> def run(self, p, - cbChangeCount, - strSequentialPrompt: str, - strRandomPrompt: str, - slResultTypeStrength, - ddResultType, - ddResultMood, - ddResultColors, - ddResultView, - ddFocusOn, - sliImageStyleStrength, - selResultStyle, - sliImageArtistStrength, - selArtist, - ): - + cbChangeCount, + strSequentialPrompt: str, + strSubSequentialPrompt: str, + strRandomPromptA: str, + strRandomPromptB: str, + strRandomPromptC: str, + slResultTypeStrength, + ddCoreResultType, + ddResultDirection, + slResultDirectionStrength, + ddResultMood, + slResultMoodStrength, + ddResultColors, + selArtMovementStrengthA, + selArtMovementA, + selArtMovementStrengthB, + selArtMovementB, + selArtMovementStrengthC, + selArtMovementC, + sliImageArtistStrengthA, + selArtistA, + sliImageArtistStrengthB, + selArtistB, + sliImageArtistStrengthC, + selArtistC, + cbShowTips + ): + # If it's all empty just exit function. if len(p.prompt) == 0: - print(f"\nEmpty prompt! It helps to have at least some guidance for SD. Remember to insert an [X] or [R] into main prompt if you want to use variable values.") + print( + f"\nEmpty prompt! It helps to have at least some guidance for SD. Remember to insert an [X], [A] or [B] into main prompt if you want to use variable values.") return - - p.do_not_save_grid = True - - # Preset the selection variables - MainType = "" - MainStyle = "" - MainArtist = "" - - if BeforeResultType[ddResultType] != "": - MainType = "(" + BeforeResultType[ddResultType] + ":" + str(slResultTypeStrength) + ") of " - - if ResultStyle[selResultStyle] != "": - MainStyle = ",(" + ResultStyle[selResultStyle] + ":" + str(sliImageStyleStrength) + ")" - - if Artists[selArtist] != "": - MainArtist = " (" + Artists[selArtist] + ":" + str(sliImageArtistStrength) + ")" # Batch lines present? BatchLines = [x.strip() for x in strSequentialPrompt.splitlines()] LineCount = len(BatchLines) - # Any random lines present? - RandomLines = [r.strip() for r in strRandomPrompt.splitlines()] + SubBatchLines = [x.strip() + for x in strSubSequentialPrompt.splitlines()] + SubLineCount = len(SubBatchLines) + + TempText = "" + SubTempText = "" images = [] + # Overtake amounts of things to generate so we can go through different variables JobCount = p.n_iter + p.n_iter = 1 + IterCount = p.batch_size + p.batch_size = 1 # If we have [X] variables use their amount, unless unchecked if cbChangeCount == True and len(strSequentialPrompt) > 0: JobCount = LineCount - # Overtake amounts of things to generate so we can go through different variables - - p.batch_size = 1 - p.n_iter = 1 - # Boasting ;) - print(f"\nStylePile helping you make great Art going through {JobCount} lines, {IterCount} iterations each:") + SubCycleCount = 1 + + if SubLineCount > 0: + SubCycleCount = SubLineCount + + # Any random lines present? + RandomLinesA = [r.strip() for r in strRandomPromptA.splitlines()] + RandomLinesB = [r.strip() for r in strRandomPromptB.splitlines()] + RandomLinesC = [r.strip() for r in strRandomPromptC.splitlines()] + + state.job_count = JobCount * IterCount * SubCycleCount CurrentChoice = 0 - TempText = "" + SubCurrentChoice = 0 + + FinalResultDirection = "" for x in range(JobCount): + SeedStep = 0 + + AllMovements = "" + AllArtists = "" + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + # Large artist selection + if selArtistA != "Not set": + # If Random is selected then pick a random artist + if selArtistA == "Random": + AllArtists += ",(by Artist " + random.choice(ResultArtistList) + \ + ":" + str(sliImageArtistStrengthA) + ")" + # otherwise use the selected value + else: + AllArtists += ",(by Artist " + selArtistA + \ + ":" + str(sliImageArtistStrengthA) + ")" + + if selArtistB != "Not set": + if selArtistB == "Random": + AllArtists += ",(by Artist " + random.choice(ResultArtistList) + \ + ":" + str(sliImageArtistStrengthB) + ")" + else: + AllArtists += ",(by Artist " + selArtistB + \ + ":" + str(sliImageArtistStrengthB) + ")" + + if selArtistC != "Not set": + if selArtistC == "Random": + AllArtists += ",(by Artist " + random.choice(ResultArtistList) + \ + ":" + str(sliImageArtistStrengthC) + ")" + else: + AllArtists += ",(by Artist " + selArtistC + \ + ":" + str(sliImageArtistStrengthC) + ")" + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + # Large style selection + if selArtMovementA != "Not set": + if selArtMovementA == "Random": + AllMovements += ",(" + random.choice(ArtMovementList) + ":" + str(selArtMovementStrengthA) + ")" + else: + AllMovements += ",(" + selArtMovementA + ":" + str(selArtMovementStrengthA) + ")" + + if selArtMovementB != "Not set": + if selArtMovementB == "Random": + AllMovements += ",(" + random.choice(ArtMovementList) + ":" + str(selArtMovementStrengthB) + ")" + else: + AllMovements += ",(" + selArtMovementB + ":" + str(selArtMovementStrengthB) + ")" + + if selArtMovementC != "Not set": + if ArtMovements[selArtMovementC] == "Random": + AllMovements += ",(" + random.choice(ArtMovementList) + ":" + str(selArtMovementStrengthC) + ")" + else: + AllMovements += ",(" + selArtMovementC + ":" + str(selArtMovementStrengthC) + ")" + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + for y in range(IterCount): - #Copy of the main prompt module to make batches, I guess... + + # Copy of the main prompt module to make batches, I guess... copy_p = copy.copy(p) - if p.seed != -1 and 'p.seed' in locals(): - copy_p.seed = p.seed + y + if copy_p.seed != -1: # and 'p.seed' in locals(): + copy_p.seed += SeedStep + SeedStep += 1 + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + # Clear the variables so random selection can work + FinalResultMood = "" + FinalResultColors = "" + + # Preset the selection variables + MainType = "" + + TypeFront = "" + TypePositives = "" + TypeNegatives = "" + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + # If main prompt isn't empty... + if ResultType[ddCoreResultType] != "": + # If it is random, give it a random value + if ResultType[ddCoreResultType] == "Random": + MainType = random.choice(ResultNames) + # otherwise use the selected value + else: + MainType = ddCoreResultType + + # Format our variables to merge into positive prompt... + TypeFront = "(" + ResultTypeBefore[MainType] + \ + ":" + str(slResultTypeStrength) + ") of " + TypePositives = ResultTypePositives[MainType] + TypeNegatives = ResultTypeNegatives[MainType] + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + if ddResultDirection != "Not set": + if ddResultDirection == "Random": + FinalResultDirection = " (" + random.choice( + ResultDirectionList) + ":" + str(slResultDirectionStrength) + ") " + else: + FinalResultDirection = " (" + ddResultDirection + \ + ":" + str(slResultDirectionStrength) + ") " + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + # Pick the mood + if ddResultMood != "Not set": + if ddResultMood == "Random": + FinalResultMood = ",(" + random(ResultMoodList) + \ + ":" + str(slResultMoodStrength) + ") " + else: + FinalResultMood = ",(" + ddResultMood + \ + ":" + str(slResultMoodStrength) + ") " + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> # If present, add batch element, otherwise remove that reference TempText = "" if LineCount > 0: if len(BatchLines[CurrentChoice % LineCount]) > 0: TempText = BatchLines[CurrentChoice % LineCount] - #TempText = str(BatchPrompts[CurrentChoice % LineCount].get('prompt')) - TempText = copy_p.prompt.replace("[X]",TempText) + TempText = copy_p.prompt.replace("[X]", TempText) + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> # If present, add random element, otherwise remove that reference - if len(RandomLines) > 0: - TempText = TempText.replace("[R]",random.choice(RandomLines)) + if len(RandomLinesA) > 0: + TempText = TempText.replace( + "[A]", random.choice(RandomLinesA)) else: - TempText = TempText.replace("[R]","") + TempText = TempText.replace("[A]", "") + + if len(RandomLinesB) > 0: + TempText = TempText.replace( + "[B]", random.choice(RandomLinesB)) + else: + TempText = TempText.replace("[B]", "") + + if len(RandomLinesC) > 0: + TempText = TempText.replace( + "[C]", random.choice(RandomLinesC)) + else: + TempText = TempText.replace("[C]", "") + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + # Colors + if ResultColors[ddResultColors] == "Random": + FinalResultColors = random.choice( + list(ResultColorList.values())) + else: + FinalResultColors = ResultColors[ddResultColors] + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> # Our main prompt composed of all the selected elements - TempText = MainType + ResultMood[ddResultMood] + TempText + MainArtist + ResultType[ddResultType] + MainStyle + ResultColors[ddResultColors] + ImageView[ddResultView] + FocusOn[ddFocusOn] + MainPositive = TypeFront + FinalResultDirection + FinalResultMood + TempText + \ + AllArtists + TypePositives + AllMovements + \ + FinalResultColors # + FocusOn[ddFocusOn] - # Clean up positive prompt - TempText = " ".join(TempText.split()) - TempText = TempText.replace(" ,",",") - TempText = TempText.replace(",",",") - TempText = TempText.strip(",") - TempText = TempText.strip() + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> - copy_p.prompt = TempText + for z in range(SubCycleCount): - # Clean up negative prompt - TempText = p.negative_prompt + ResultTypeNegatives[ddResultType] + FocusOnNegatives[ddFocusOn] + AlwaysBad + SubTempText = "" + if SubLineCount > 0: + if len(SubBatchLines[SubCurrentChoice % SubLineCount]) > 0: + SubTempText = SubBatchLines[SubCurrentChoice % + SubLineCount] - TempText = " ".join(TempText.split()) - TempText = TempText.replace(" ,",",") - TempText = TempText.replace(",",",") - TempText = TempText.strip(",") - TempText = TempText.strip() + TempText = MainPositive.replace("[Y]", SubTempText) - copy_p.negative_prompt = TempText + # Clean up positive prompt + TempText = " ".join(TempText.split()) + TempText = TempText.replace(",,", ",") + TempText = TempText.replace(" ,", ",") + TempText = TempText.replace(",", ",") + TempText = TempText.strip(",") + TempText = TempText.strip() - # Add information in command prompt window - - print(f"[Prompt {x+1}/{JobCount}|Iteration {y+1}/{IterCount}|Seed {copy_p.seed}] >>> Positives <<< {copy_p.prompt} >>> Negatives <<< {copy_p.negative_prompt}") + copy_p.prompt = TempText + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + + # Clean up negative prompt + TempText = copy_p.negative_prompt + TypeNegatives + \ + AlwaysBad # + FocusOnNegatives[ddFocusOn] # + AlwaysBad + + TempText = " ".join(TempText.split()) + TempText = TempText.replace(",,", ",") + TempText = TempText.replace(" ,", ",") + TempText = TempText.replace(",", ",") + TempText = TempText.strip(",") + TempText = TempText.strip() + + copy_p.negative_prompt = TempText + + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> + # Add information in command prompt window and process the image + + print(f"\n\n[Prompt {x+1}/{JobCount}][Iteration {y+1}/{IterCount}][SubPrompt {z}/{SubLineCount} {SubTempText}][Seed {int(copy_p.seed)}] >>> Positives <<< {copy_p.prompt} >>> Negatives <<< {copy_p.negative_prompt}\n") + + proc = process_images(copy_p) + images += proc.images + + SubCurrentChoice += 1 - proc = process_images(copy_p) - images += proc.images CurrentChoice += 1 p.batch_size = JobCount p.n_iter = IterCount - - return Processed(p,images,p.seed,"") - print(f"\nStylePile processing complete. Have a nice day.") \ No newline at end of file + + if cbShowTips: + print( + f"\n\nStylePile processing complete. Here's a random tip:\n{random.choice(TipsAndTricks)}\n") + + # return Processed(p,images,p.seed,p.prompt) + + return Processed(p, images, p.seed, "Positives: " + p.prompt + "\nNegatives:" + p.negative_prompt + "\nSeed: " + str(p.seed))