Created
January 12, 2024 06:09
-
-
Save daveschumaker/a1a3d22dfd6cb3f649ffe6271666a5e1 to your computer and use it in GitHub Desktop.
Poor Man's Prompt Expansion for Stable Diffusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Various Stable Diffusion models massively benefit from prompt descriptions that contain | |
* additional descriptors. Much recent research has gone into training text generation models for | |
* expanding existing Stable Diffusion prompts with relevant and context appropriate descriptors. | |
* | |
* Since it isn't feasible to run LLMs and text generation models inside most users' web browsers | |
* at this time, I present my "Poor Man's Prompt Expansion Model". It uses a number of examples | |
* I've acquired from Fooocus and Hugging Face to generate completely random | |
* (though not context appropriate) prompt expansions. | |
*/ | |
const suffixes = [ | |
// Returned via local Fooocus install | |
// https://github.com/lllyasviel/Fooocus | |
', vibrant colors, colorful, dramatic atmosphere, creative, positive, detailed, sharp focus, intricate, engaging, cinematic, highly detail, rich bright, color, clear, attractive, epic, best, novel, surreal, dynamic, beautiful, scenic, thought, perfect, sunny, calm, unique', | |
', bright colors, highly detailed, dramatic light, cinematic background, sharp, fine detail, inspired very intricate, innocent, fair, complex, colorful, color, ambient dynamic, radiant, professional, extremely, fresh, amazing, creative, daring, beautiful, confident, passionate, pretty, illuminated, cute', | |
', intricate, elegant, highly detailed, wonderful colors, glowing, sharp focus, perfect composition, full color, cinematic atmosphere, dynamic dramatic, lively, unique, very inspirational, original, thoughtful, colorful, positive, loving, pretty, inspiring, professional, artistic, best, winning, real, imagined, creative', | |
', vibrant colors, ambient light, dynamic dramatic cinematic color, precise perfect composition, aesthetic, very inspirational, stunning, intricate, inspiring, highly saturated, original, fine detail, full focus, beautiful, artistic, extremely thoughtful, confident, passionate, rich, spiritual, colorful', | |
', highly detailed, sharp focus, still, fine detail, full composition, cinematic, new classic, futuristic, dramatic colors, color, open background, dynamic, contemporary, creative, elegant, calm, artistic, intricate, very inspirational, vibrant, determined, incredible, inspiring, extremely, positive', | |
', stunning, sharp focus, cinematic, elegant, intricate, highly detailed, very inspirational, innocent, fine, depicted, epic elaborate full color, dramatic background, colorful, real, atmosphere, radiant, strong, emotional, gorgeous, light, crisp, extremely detail, clear, artistic, winning, complex, enhanced, loving, caring, generous, cheerful', | |
', deep focus, beautiful, highly detailed, perfect composition, dramatic light, sharp, intricate, elegant, dynamic, vibrant colors, inspired, designed, brave, glowing, epic, stunning, gorgeous, amazing, cinematic, consistent, brilliant, creative, cool, illuminated, best, unique, awesome, winning, cute, incredible, colorful', | |
' background dramatic ambient light, dynamic colors, cinematic, professional, extremely detailed, beautiful, stunning, sharp focus, highly detail, intricate, elegant, epic, winning composition, clear, amazing color, creative, positive, joyful, unique, radiant, loving, symmetry, flowing, complex, vibrant, glowing, colorful, consistent, enhanced', | |
', highly detailed, cinematic, professional composition, dramatic light, expressive, emotional, vibrant colors, beautiful background, intricate, elegant, very inspirational, thought, fancy, clear, artistic, winning, new, creative, positive, joyful, unique, cute, confident, iconic, shiny, colorful, illuminated, determined, pretty, friendly', | |
', deep focus, beautiful, highly detailed, perfect colorful, atmosphere cinematic, dynamic light, silent, pristine, strong, solid, artistic, full color, epic, grand, dramatic, detail, intricate, majestic, elegant, sharp, best, emotional, professional, innocent, gorgeous, depicted, vivid, fine, imposing, complex', | |
', deep focus, intricate, elegant, highly detailed, focused, bright colors, symmetry, illuminated background, fine detail, cinematic, unique, attractive, full color, beautiful, artistic, true magic, pure, fair, calm, cute, magical, enchanted, professional, pretty, creative, best, dramatic, charming, clear, perfect', | |
', intricate, elegant, highly detailed, bright colors, sharp, clear, excellent composition, cinematic atmosphere, dynamic light, attractive, confident, innocent, aesthetic, extremely inspirational, color, fine detail, full background, colorful, beautiful, stunning, creative, positive, cute, cheerful, artistic, vibrant, enhanced, glowing', | |
', highly detailed, dramatic light, illuminated background, intricate, elegant, sharp focus, cinematic, fine composition, new classic, modern, futuristic, color saturated, imposing, epic, professional, best, dynamic, creative, fair, attractive, beautiful, unique, cute, adorable, advanced, cool, awesome, gorgeous, brilliant', | |
', cinematic, highly detailed, excellent composition, dynamic dramatic atmosphere, precise perfect artistic color, aesthetic, very inspirational, glowing, deep vivid colors, inspired, innocent, fine detail, full bright awesome, creative, winning new novel, light, best spread, beautiful, cute, surreal, iconic, sharp, fantastic, epic, hopeful', | |
// Prompt extend via Hugging Face: | |
// https://huggingface.co/spaces/daspartho/prompt-extend | |
// https://github.com/daspartho/prompt-extend | |
', realistic concept art, hyper detailed, artstation, Art by greg rutkowski mythologic concept art, smooth, sharp focus, illustration, cinematic masterpiece. octane render, perfect anatomy, ray tracing, golden ratio, rule of thirds, unity', | |
', by Makoto Shinkai, Stanley Artgerm Lau, WLOP, Rossdraws, James Jean, Andrei Riabovitchev, Marc Simonetti, krenz', | |
', photorealistic, detailed, trending on artstation, volumetric lighting, bokeh, HDR, octane render, weta digital, micro details, 3d structure, ray trace, insane details, intricate, elite, ornate, elegant, luxury, dramatic', | |
', artwork by Aaron Miller, highly detailed, soft lighting, concept art, fantasy background, sharp focus, illustration, art by Viktor Vasnetsov, octane render, volumetric lighting, 8k, artstation, HD, hyper-detailed, cinematic', | |
', vector, pixta.jp, hd, 4k, svg, vector art, adobe illustrator, vector art, award winning, black and white, behance, dribbble, by Bill Sienkiewicz, by Frank Weston, by Akira, trending', | |
', realistic, photograph, detailed, HD, well lit, high quality, artstation, Deviantart, Furaffinity, 8k HD render, epic lighting, depth of field, by Syd Mead, Mariusz Lewandowski, Houdini algorithmic generative render, full', | |
', digital art,knot, shorts, bow on the chair, high quality, highly detailed, calm, faded colors, illustration, art, by Greg Rutkowski, trending on artstation, art by alphonse mucha', | |
', 3D render, digital art, fantasy style, artstation, dramatic lighting, highly detailed, unreal engine, concept art, sharp focus, Trending on Artstation HQ, deviantart, 4K UHD image, octane render, unreal engine 5', | |
', 8k, professional photography, cinematic shot from the side, studio light, high contrast, epic artstation, realistic, blue sky, dramatic, clouds, hdr, detailed, high quality, cinematic, artstation realistic, 70', | |
', sitting on a rock, next to a dog. Fully. By Norman Rockwell. By Raphael Raphael. painting with vivid colors. color. Hyper-detailed. Profound. 8K. Intricate. Sharp. Stunning. Breathtaking', | |
', digital painting, hyperrealism, photo-realistic, highly detailed, cyberpunk, trending on artstation, colourful, lasers in the eyes, detailed, sharp, focused, Unreal Engine 5, octane render, vray, redshift, 3D', | |
', photorealistic, cinematic, sharp focus, highly detailed, octane render 4k, volumetric lit lighting, ray tracing, high contrast, intricate, masterpiece, Artstation, behance, art by Basil Gogos, by Bob Ross, by Stephen Gammell', | |
', by Salvador Dali, detailed, masterpiece, trending on ArtStation, devianart, cgsociety, ultra HD, 8K, high quality detail, no watermark, vector, funny, humorous, no blur, by Chris Mars, by Grant Wood', | |
', digital art, vector illustration, trending on artstation, art by Laurie Lipton, 4k wallpaper, neon colours, lens flare, intricate, surreal, sharp focus, masterpiece, detailed, hyperrealistic, award winning, unreal engine 5', | |
', oil painting by Caravaggio, oil on canvas, detailed brushstrokes, beautiful brush strokes, artstation, masterpiece, award-winning, dramatic lighting, sharp, details, hyper-detailed, HD, HDR, 4K, 8K', | |
', oil painting, colorful, highly detailed, masterpiece, aesthetic, award winning, sharp focus, intricate details, realistic iris, van herpen, artstation, unreal engine, octane render, natural light, photo by subject in the center of', | |
', cinematic angle, studio Ghibli, cinematic lighting, detailed oil painting, hyperrealistic, 8k, beautiful scene, masterpiece, trending on artstation, cgsociety, octane render, cinematic, unreal engine, vray, volumetric lighting, atmospheric lighting', | |
', oil painting, high detail, trending on art station, 8k. vibrant colours, award winning photo. Sigma 85mm f/1.4, exposure. Studio Light. High Definition, 8K, sharpened, upscaled', | |
', by Studio Ghibli, anime, trending on art station, 8k, highly detailed, high quality, godrays, complementary colours, beautiful lighting, cartoon artstyle, sharp, 4K, ghibli anime art, happy lighting, funny animation', | |
', professional photography, DSLR, DSLR 100mm, bokeh, depth of field, black and white, award winning, 4k, 8k, hd. H 768, hyperdetailed. Shutterstock, by Annie Leibovitz, David Bailey', | |
', digital art, highly detailed, trending on artstation, award winning art, 8k, in the style of vintage horror Comics, by Alex Ross, and Norman Rockwell, dark, moody lighting, oil on canvas, octane render.', | |
', photorealistic 3d Render, octane render, vibrant colors, high resolution. best of artstation, exquisite detail, soft light, cinematic, 8k HD Resolution HD, 8k resolution, inspired by Tron, of cheese, by A', | |
', by Michael Sowa, by William Adolphe Bouguereau, by John Singer Sargent, pastel colors, pastels, gold, cotton, architecture, oil on canvas, 8k, hd, trending on artstation, featured on pixiv, masterpiece, cinematic', | |
', digital art, illustration, artstation, fanart, pinterest, sci fi, CGI, Hyper realism, Unreal Engine, Photorealism, High Resolution, 8k, High quality, post processing, ultra-details, Octane render, digital art', | |
', oil painting, drawn in the style of Basquiat, colorful, high-detailed, artstation, brush strokes, painted by Francis Bacon and Edward Hopper, painted by James Gilleard, surrealism, airbrush, Ilya Kuvshinov, WLOP, Stanley Artgerm', | |
', octane render, trending on artstation, artstationHQ, artstationHD, unreal engine, 4k, 8k', | |
', detailed watercolour, 4k, hd. hq, high resolution. highly detailed. trending on artstation. Realistic materials. dramatic lighting. symmetrical faces. character concept. cinematic scene. epic. ultra realistic', | |
', digital art, trending on artstation, high-quality wallpaper, realistic and detailed, detailed, UHD 8K, HDR, octane render, ray tracing, trending on Artstation, unreal engine 5, photorealistic', | |
',digital art,trending on artstation,ultra realistic,unreal engine 5,4k,cinematic lighting,neon colors,sci fi,sunset,muted,raytracing,rtx,highly realistic,8k', | |
', in a futuristic, highly detailed, hyper realistic, 4K, HD, octane render, unreal engine, 8k, reflected on the matrix studio background, matte painting hyperrealistic, trending on artstation', | |
', octane render, hyperrealistic, 35mm, unreal, depth of field, blender, trending on artstation, 8k, highly detailed, high quality, concept art, full length, Unreal Engine 5 render', | |
', 4k, photograph, photorealistic, 4k resolution, 8k, photorealistic imagery, trending on artstation, artstation, artstation digital art, detailed, intricate, elegant, profile picture, art by Greg', | |
', digital art, highly detailed, trending on artstation, artstation, award winning, concept art, sharp focus, illustration, art by artgerm and greg rutkowski and magali villeneuve, cinematic lighting, red background yellow', | |
', artstation, cgsociety, deviantart, vibrant, realistic, intricate, detailed, masterpiece, stunning, gorgeous, 4k octane render, unreal engine, ray tracing, volumetric lighting, depth of field, ambient', | |
', digital art style, highly detailed, high quality, coherent, realistic, artstation, anime lightning, studio photo, official media, smooth, hd, octane render, award winning, designed', | |
', photorealistic photography, 8K HD award-winning. hyperrealism, 4k resolution, HDR, cinematic, crisp, sharp focus, gorgeous, great power, award winning, artstation, photorealistic, masterpiece', | |
', painted by John William Waterhouse and John Singer Sargent, still from a Wes Anderson movie by Denis Villeneuve and Wes Anderson, wide lens, bokeh, 4K, cinematic, symmetrical faces, very detailed', | |
', dramatic, art style by Norman Rockwell and Boris Vallejo and Frank Frazetta, artstation, concept art, 4k, 8k, HDR, sharp focus, octane render, rtx on, perfect face', | |
', digital art in the style of Salvador Dali and Frank Frazetta on a computer screen, award-winning illustration, rending on artstation, artstationHQ, 4k, 8k, HD, beautiful color palette', | |
', realistic photo high detailed picture, trending on artstation, 8K, hyperreal, soft focus, melanchonic highlights, volumetric dramatic lighting, unreal engine, octane render, quixel megascan, intricate, detailed illustration', | |
', artstation, digital 2d drawing, award winning. Very detailed 8k wallpaper, Cinematic lighting, Unreal Engine, hyperrealistic, photorealistic, HD, cinematic, high details, dramatic, trending on Artstation', | |
', photo, HD, 4k, award winning, beautiful, look at all that detail! amazing! real life! dream beautiful!! very detailed. hyperrealistic. photorealistic. ultra HD. 8k resolution', | |
', oil on canvas, trending on artstation, artstationHQ, artstationHD, 4k, 8k, art deco, Fantastic intriguing, Fantastic intriguing, Very detailed, Unreal engine, ArtStation, Digital', | |
', detailed photo, well-lit, 4k, by Salvador Dali, by Beeple, intricate, hyperrealistic, volumetric lighting, epic composition, HD, masterpiece, trending on artstation, HDR, 8K', | |
', realistic 4k octane beautifully detailed render, 4k post-processing, highly detailed, intricate complexity, epic composition, magical atmosphere, cinematic lighting, masterpiece, ultra hd, trending on artstation, masterpiece', | |
', realistic photograph, 4k, high definition, masterpiece. digital art, Trending on Artstation, by Alena Aenami, by Petros Afshar, by artgerm, by Eddie Mendoza, by Peter mohrbacher, octane render', | |
', digital art, trending on artstation, high detail, sharp, high quality, masterpiece ', | |
', 8k photorender cute hyper-realism trending on artstation volumetric lighting professional surrealism by beeple zdzisław beksiński and Salvador Dali', | |
', 3D, digital art, sharp focus, Trending on Artstation HQ, deviantart', | |
', detailed face, fantasy, highly detailed, cinematic lighting, digital art painting by greg rutkowski. magic the gathering, trending on artstation, ultra realistic, 4k, octane render, raytracing, wide shot, concept art', | |
',artwork by Peter Mohrbacher and Craig Mullins, James Jean, tom bagshaw, trending on artstation, volumetric lighting, hyper realism, octane render, 8k, hyper detailed. vivid. vibrant. green', | |
', by Francisco Goya, oil on canvas, masterpiece, detailed, dramatic composition, trending on artstation, 4k, 8k, HD. intricately detailed. intricate detail, museum quality, golden ratio, mythological', | |
', painting by William-Adolphe Bouguereau and Ilya Kuvshinov, masterpiece, 4k wallpaper, dynamic lighting, intricate detail, full view, Trending on artstation, octane render, artstationHD, artstationHQ, unreal engine, 8k', | |
', ukiyo-e, hokusai style, high quality art, 4k, ultra detailed., masterpiece, stunning, deep atmosphere, bright colors. High resolution. octane render. trending on artstation, art by canaletto', | |
', painting by Claude Monet, sharp focus, masterpiece, highly detailed, intricate, 4k, artstation, pixiv, stunning composition, dynamic lighting, intricate facial features, 4k resolution, 8k resolution, HD', | |
', guitar solo, oil painting by Caravaggio, dramatic lightning from lightning, masterpiece, detailed, 8k resolution, smooth, sharp focus, trending on artstation, by Alena Aenami, by Noah Bradley, by Thomas Kinkade', | |
', concert photography, cinematic, beautiful composition, high quality, 4k uhd, 8k, digital art, best of artstation, wide shot, many hearts artstation, deviantart, pinterest, dynamic dramatic lighting, energetic', | |
', renaissance painting by John Singer Sargent, Caravaggio, Paul Klee, Pablo Picasso, Pablo Picasso, Japanese Gothic, 4k 8k UHD, sharp focus, Highly Detailed, Intricate, masterpiece, award winning, fantastic', | |
', is surrounded by crowd, digital art, amazing composition, by David Nabarrel, trending on artstation, award winning painting, concept art, sharp focus', | |
', oil and acrylic paint, in the style of Picasso, masterpiece, award-winning, detailed, trending on artstation, 4k, 8k, HD, octane render, unreal engine 5, redshift render, photo' | |
]; | |
function generateDetailedPrompt(basicPrompt) { | |
// Helper function to get a random integer within a range. | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
// Helper function to check if the phrase already exists. | |
function phraseExists(existingText, phrase) { | |
const normalizedText = existingText.toLowerCase(); | |
const normalizedPhrase = phrase.toLowerCase().trim(); | |
return normalizedText.includes(normalizedPhrase); | |
} | |
// Flatten all the phrases from the suffixes into one array. | |
const allPhrases = suffixes.flatMap(suffix => suffix.split(',').map(phrase => phrase.trim())); | |
// Function to create a unique and length-specific suffix. | |
function createSuffix() { | |
let detailedSuffix = ''; | |
let suffixLength = 0; | |
const maxLength = getRandomInt(175, 220); | |
while (suffixLength < maxLength && allPhrases.length > 0) { | |
const randomIndex = getRandomInt(0, allPhrases.length - 1); | |
const phrase = allPhrases[randomIndex]; | |
if (!phraseExists(basicPrompt, phrase) && !phraseExists(detailedSuffix, phrase)) { | |
const phraseWithComma = detailedSuffix.length > 0 ? `, ${phrase}` : phrase; | |
if ((suffixLength + phraseWithComma.length) <= maxLength) { | |
detailedSuffix += phraseWithComma; | |
suffixLength += phraseWithComma.length; | |
} | |
} | |
// Remove the selected phrase from the array to avoid duplication. | |
allPhrases.splice(randomIndex, 1); | |
} | |
return detailedSuffix; | |
} | |
const detailedSuffix = createSuffix(); | |
return `${basicPrompt}, ${detailedSuffix}`; | |
} | |
// Example usage: | |
const userPrompt = "A cat shredding on an electric guitar"; | |
const detailedPrompt = generateDetailedPrompt(userPrompt); | |
console.log(`Result:`, detailedPrompt); | |
/** | |
* Result: | |
* A cat shredding on an electric guitar, intricate, colorful, hyper detailed, | |
* hyper-detailed, complex, art by Greg, elegant, cinematic lighting, | |
* digital 2d drawing, epic, Trending on Artstation, airbrush, | |
* volumetric lighting | |
* | |
* ArtBot link: https://tinybots.net/artbot?i=zgqked9AC6r | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment