Add emoji beautifying. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit 7429173aef156876e4463fa07230c003ff8ef069 DIR parent b7639839f6f65c6cef63c8868360d3c20ed42eab HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Wed, 31 Jul 2024 17:08:01 +0200 Add emoji beautifying. Diffstat: A stable-diffusion-beautify-prompt | 300 +++++++++++++++++++++++++++++++ M stable-diffusion-emoji | 6 ++++++ 2 files changed, 306 insertions(+), 0 deletions(-) --- DIR diff --git a/stable-diffusion-beautify-prompt b/stable-diffusion-beautify-prompt @@ -0,0 +1,300 @@ +#!/usr/bin/env python +# coding=utf-8 +# +# ©2024 Christoph Lohmann <20h at r-36 dot net> +# +# This file is published under the terms of the GPLv3. +# + +import os +import sys +import getopt +import time +from datetime import datetime, timedelta +import pytz +import subprocess +import random + +def beautify_prompt(text): + # TODO: Better background handling? + #background = "background fireworks and night sky" + background = None + modifiers = [None, "cinematic", "hd", "4k", "8k", "3d", "4d", + "highly detailed", "octane render", "trending artstation", + "Pixelate", "Blur", "Symmetrical", "Macabre", "at night"] + beauties = [None, "Beautiful", "Very Beautiful", "Very Very Beautiful"] + times = [None, "ancient", "futuristic", "modern", "antique", "Retro", + "old-fashioned", "youthful"] + colors = [None, "colorful", "black and white", "greyscale"] + lightnings = [None, "daylight", "moonlight", "natural light", "Front light", + "Backlight", "Soft light", "Hard light", "Moody light", + "Dynamic light"] + styles = [None, + "Abstract Painting", + "Acrylic Painting", + "Action Painting", + "Aestheticism Painting", + "Anamorphosis Painting", + "Art Deco Painting", + "Art nouveau Painting", + "Ashcan School Painting", + "Baroque Painting", + "Body Painting", + "Canvas Painting", + "Cartoon Painting", + "Chalk Painting", + "Child's Finger Painting", + "Chinese Painting", + "Classicism Painting", + "Collage Painting", + "Cubism Painting", + "Dadaism Painting", + "De Stijl Painting", + "Der Blaue Painting", + "Digital Painting", + "Drip Painting", + "Enamel Painting", + "Encaustic Painting", + "Expressionism Painting", + "Figurativism Painting", + "Fingerpainting Painting", + "Finger Painting", + "Fresco Secco Painting", + "Futurism Painting", + "Genre Painting", + "Glitter Glue Painting", + "Gothic Painting", + "Gouache Painting", + "History Painting", + "Hot Wax Painting", + "Impressionism Painting", + "Ink Wash Painting", + "Japanese Painting", + "Korean Painting", + "Landscape Painting", + "Leaf Painting", + "Marker Painting", + "Matte Painting", + "Miniature Painting", + "Modernism Painting", + "Mughal Painting", + "Mural Painting", + "Oil Painting", + "Pastel Painting", + "Pattachitra Painting", + "Photorealism Painting", + "Rajasthan Painting", + "Realism Painting", + "Reverse Glass Painting", + "Sand Painting", + "Speed Painting", + "Spray Painting", + "Still Life Painting", + "Surrealism Painting", + "Tanjore Painting", + "Tempera Painting", + "Velvet Painting", + "Watercolor Painting", + "Anime Art", + "Bedazzled Art Style", + "Button Art", + "Chalk Art", + "Comic Book Art", + "Conceptual Art", + "Leather Art Style", + "Line Art", + "Marble Art", + "Pop Art painting", + "Portrait Art", + "Sand Art", + "Street Art", + "Woven Art", + "Anime Style", + "Atari 2600 Style", + "Bauhaus Style", + "Coloring Book Style", + "Constructivism Style", + "Fauvism Style", + "Glitter Style", + "GTAV Style", + "NES Style", + "Retro Comic Book Style", + "SNES Style", + "Studio Ghibli Style", + "Woodburning Style", + "Woodcut Style", + "Ballpoint Pen Drawing", + "Blue Ballpoint Pen Drawing", + "Colored Pencil Drawing", + "Pencil Drawing", + "Red Ballpoint Pen Drawing", + "Comic Book Cover", + "Comic Book", + "Comic Book Panel", + "Colored Pencil Sketch", + "Pencil Sketch", + "3D Render", + "Boxart", + "Children's Book", + "Coloring Book", + "Copper Plate Engraving", + "Cross-Stitch", + "Diamond Engraving", + "Icon", + "Linocut", + "Lowpoly", + "Old Black and White Photograph", + "Photograph", + "Pixelart", + "Pop Up Book", + "Ring Engraving", + "Spray Paint", + "Stained Glass", + "Sticker", + "Stone Cut" + ] + artists = [None, + "Agnes Lawrence Pelton", + "Akihito Yoshida", + "Alex Grey", + "Alexander Jansson", + "Alphonse Mucha", + "Andy Warhol", + "Artgerm", + "Asaf Hanuka", + "Aubrey Beardsley", + "Banksy", + "Beeple", + "Ben Enwonwu", + "Bob Eggleton", + "Caravaggio Michelangelo Merisi", + "Caspar David Friedrich", + "Chris Foss", + "Claude Monet", + "Dan Mumford", + "David Mann", + "Diego Velázquez", + "Disney Animation Studios", + "Édouard Manet", + "Esao Andrews", + "Frida Kahlo", + "Gediminas Pranckevicius", + "Georgia O'Keeffe", + "Greg Rutkowski", + "Gustave Doré", + "Gustave Klimt", + "H.R. Giger", + "Hayao Miyazaki", + "Henri Matisse", + "HP Lovecraft", + "Ivan Shishkin", + "Jack Kirby", + "Jackson Pollock", + "James Jean", + "Jim Burns", + "Johannes Vermeer", + "John William Waterhouse", + "Katsushika Hokusai", + "Kim Tschang Yeul", + "Ko Young Hoon", + "Leonardo da Vinci", + "Lisa Frank", + "M.C. Escher", + "Mahmoud Saïd", + "Makoto Shinkai", + "Marc Simonetti", + "Mark Brooks", + "Michelangelo", + "Pablo Picasso", + "Paul Klee", + "Peter Mohrbacher", + "Pierre-Auguste Renoir", + "Pixar Animation Studios", + "Rembrandt", + "Richard Dadd", + "Rossdraws", + "Salvador Dalí", + "Sam Does Arts", + "Sandro Botticelli", + "Ted Nasmith", + "Ten Hundred", + "Thomas Kinkade", + "Tivadar Csontváry Kosztka", + "Victo Ngai", + "Vincent Di Fate", + "Vincent van Gogh", + "Wes Anderson", + "wlop", + "Yoshitaka Amano" + ] + style = random.choice(styles) + modifier = random.sample(modifiers, random.randint(0, len(modifiers))) + artist = random.choice(artists) + time = random.choice(times) + color = random.choice(colors) + lighting = random.choice(lightnings) + beauty = random.choice(beauties) + + etexta = [] + if beauty != None: + etexta.append(beauty) + if time != None: + etexta.append(time) + if style != None: + etexta.append(style) + if text != None: + etexta.append(text) + if background != None: + etexta.append("with") + etexta.append(background) + if artist != None: + etexta.append("by") + etexta.append(artist) + if len(modifier) > 0: + etexta.append(",") + modifiertext = "" + for m in modifier: + if m != None: + if len(modifiertext) > 0: + modifiertext += " " + modifiertext += str(m) + etexta.append(modifiertext) + if lighting != None: + etexta.append(",") + etexta.append(lighting) + if color != None: + etexta.append(",") + etexta.append(color) + etext = " ".join(etexta) + + return etext + +def usage(app): + app = os.path.basename(app) + print("usage: %s [-hft] [-c chan] [-d description] [-s sleept] YYYY-mm-dd" % (app),\ + file=sys.stderr) + sys.exit(1) + +def main(args): + try: + opts, largs = getopt.getopt(args[1:], "h") + except getopt.GetoptError as err: + print(str(err)) + usage(args[0]) + + for o, a in opts: + if o == "-h": + usage(args[0]) + else: + assert False, "unhandled option" + + if len(largs) < 1: + usage(args[0]) + + text = " ".join(largs) + print(beautify_prompt(text)) + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv)) + DIR diff --git a/stable-diffusion-emoji b/stable-diffusion-emoji @@ -26,6 +26,12 @@ emojiorig="${emojifilebase}.orig" if [ ! -e "${emojidb}/${emojifile}" ]; then + case "${emojiprompt}" in + *beautify*) + emojiprompt="$(stable-diffusion-beautify-prompt "${emojiprompt}")" + ;; + esac + SD_MODEL="/br/ai/stable-diffusion.cpp/models/epicphotogasm_x-ggml-model-f16.bin" \ stable-diffusion "${emojidb}/${emojifile}" "${emojiprompt}" if [ -e "${emojidb}/${emojifile}" ];