URI: 
       stable-diffusion-beautify-prompt - 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
       ---
       stable-diffusion-beautify-prompt (6608B)
       ---
            1 #!/usr/bin/env python
            2 # coding=utf-8
            3 #
            4 # ©2024 Christoph Lohmann <20h at r-36 dot net>
            5 #
            6 # This file is published under the terms of the GPLv3.
            7 #
            8 
            9 import os
           10 import sys
           11 import getopt
           12 import time
           13 from datetime import datetime, timedelta
           14 import pytz
           15 import subprocess
           16 import random
           17 
           18 def beautify_prompt(text):
           19         # TODO: Better background handling?
           20         #background = "background fireworks and night sky"
           21         background = None
           22         modifiers = [None, "cinematic", "hd", "4k", "8k", "3d", "4d",
           23                 "highly detailed", "octane render", "trending artstation",
           24                 "Pixelate", "Blur", "Symmetrical", "Macabre", "at night"]
           25         beauties = [None, "Beautiful", "Very Beautiful", "Very Very Beautiful"]
           26         times = [None, "ancient", "futuristic", "modern", "antique", "Retro",
           27                 "old-fashioned", "youthful"]
           28         colors = [None, "colorful", "black and white", "greyscale"]
           29         lightnings = [None, "daylight", "moonlight", "natural light", "Front light", 
           30                 "Backlight", "Soft light", "Hard light", "Moody light",
           31                 "Dynamic light"]
           32         styles = [None,
           33                 "Abstract Painting",
           34                 "Acrylic Painting",
           35                 "Action Painting",
           36                 "Aestheticism Painting",
           37                 "Anamorphosis Painting",
           38                 "Art Deco Painting",
           39                 "Art nouveau Painting",
           40                 "Ashcan School Painting",
           41                 "Baroque Painting",
           42                 "Body Painting",
           43                 "Canvas Painting",
           44                 "Cartoon Painting",
           45                 "Chalk Painting",
           46                 "Child's Finger Painting",
           47                 "Chinese Painting",
           48                 "Classicism Painting",
           49                 "Collage Painting",
           50                 "Cubism Painting",
           51                 "Dadaism Painting",
           52                 "De Stijl Painting",
           53                 "Der Blaue Painting",
           54                 "Digital Painting",
           55                 "Drip Painting",
           56                 "Enamel Painting",
           57                 "Encaustic Painting",
           58                 "Expressionism Painting",
           59                 "Figurativism Painting",
           60                 "Fingerpainting Painting",
           61                 "Finger Painting",
           62                 "Fresco Secco Painting",
           63                 "Futurism Painting",
           64                 "Genre Painting",
           65                 "Glitter Glue Painting",
           66                 "Gothic Painting",
           67                 "Gouache Painting",
           68                 "History Painting",
           69                 "Hot Wax Painting",
           70                 "Impressionism Painting",
           71                 "Ink Wash Painting",
           72                 "Japanese Painting",
           73                 "Korean Painting",
           74                 "Landscape Painting",
           75                 "Leaf Painting",
           76                 "Marker Painting",
           77                 "Matte Painting",
           78                 "Miniature Painting",
           79                 "Modernism Painting",
           80                 "Mughal Painting",
           81                 "Mural Painting",
           82                 "Oil Painting",
           83                 "Pastel Painting",
           84                 "Pattachitra Painting",
           85                 "Photorealism Painting",
           86                 "Rajasthan Painting",
           87                 "Realism Painting",
           88                 "Reverse Glass Painting",
           89                 "Sand Painting",
           90                 "Speed Painting",
           91                 "Spray Painting",
           92                 "Still Life Painting",
           93                 "Surrealism Painting",
           94                 "Tanjore Painting",
           95                 "Tempera Painting",
           96                 "Velvet Painting",
           97                 "Watercolor Painting",
           98                 "Anime Art",
           99                 "Bedazzled Art Style",
          100                 "Button Art",
          101                 "Chalk Art",
          102                 "Comic Book Art",
          103                 "Conceptual Art",
          104                 "Leather Art Style",
          105                 "Line Art",
          106                 "Marble Art",
          107                 "Pop Art painting",
          108                 "Portrait Art",
          109                 "Sand Art",
          110                 "Street Art",
          111                 "Woven Art",
          112                 "Anime Style",
          113                 "Atari 2600 Style",
          114                 "Bauhaus Style",
          115                 "Coloring Book Style",
          116                 "Constructivism Style",
          117                 "Fauvism Style",
          118                 "Glitter Style",
          119                 "GTAV Style",
          120                 "NES Style",
          121                 "Retro Comic Book Style",
          122                 "SNES Style",
          123                 "Studio Ghibli Style",
          124                 "Woodburning Style",
          125                 "Woodcut Style",
          126                 "Ballpoint Pen Drawing",
          127                 "Blue Ballpoint Pen Drawing",
          128                 "Colored Pencil Drawing",
          129                 "Pencil Drawing",
          130                 "Red Ballpoint Pen Drawing",
          131                 "Comic Book Cover",
          132                 "Comic Book",
          133                 "Comic Book Panel",
          134                 "Colored Pencil Sketch",
          135                 "Pencil Sketch",
          136                 "3D Render",
          137                 "Boxart",
          138                 "Children's Book",
          139                 "Coloring Book",
          140                 "Copper Plate Engraving",
          141                 "Cross-Stitch",
          142                 "Diamond Engraving",
          143                 "Icon",
          144                 "Linocut",
          145                 "Lowpoly",
          146                 "Old Black and White Photograph",
          147                 "Photograph",
          148                 "Pixelart",
          149                 "Pop Up Book",
          150                 "Ring Engraving",
          151                 "Spray Paint",
          152                 "Stained Glass",
          153                 "Sticker",
          154                 "Stone Cut"
          155         ]
          156         artists = [None,
          157                 "Agnes Lawrence Pelton",
          158                 "Akihito Yoshida",
          159                 "Alex Grey",
          160                 "Alexander Jansson",
          161                 "Alphonse Mucha",
          162                 "Andy Warhol",
          163                 "Artgerm",
          164                 "Asaf Hanuka",
          165                 "Aubrey Beardsley",
          166                 "Banksy",
          167                 "Beeple",
          168                 "Ben Enwonwu",
          169                 "Bob Eggleton",
          170                 "Caravaggio Michelangelo Merisi",
          171                 "Caspar David Friedrich",
          172                 "Chris Foss",
          173                 "Claude Monet",
          174                 "Dan Mumford",
          175                 "David Mann",
          176                 "Diego Velázquez",
          177                 "Disney Animation Studios",
          178                 "Édouard Manet",
          179                 "Esao Andrews",
          180                 "Frida Kahlo",
          181                 "Gediminas Pranckevicius",
          182                 "Georgia O'Keeffe",
          183                 "Greg Rutkowski",
          184                 "Gustave Doré",
          185                 "Gustave Klimt",
          186                 "H.R. Giger",
          187                 "Hayao Miyazaki",
          188                 "Henri Matisse",
          189                 "HP Lovecraft",
          190                 "Ivan Shishkin",
          191                 "Jack Kirby",
          192                 "Jackson Pollock",
          193                 "James Jean",
          194                 "Jim Burns",
          195                 "Johannes Vermeer",
          196                 "John William Waterhouse",
          197                 "Katsushika Hokusai",
          198                 "Kim Tschang Yeul",
          199                 "Ko Young Hoon",
          200                 "Leonardo da Vinci",
          201                 "Lisa Frank",
          202                 "M.C. Escher",
          203                 "Mahmoud Saïd",
          204                 "Makoto Shinkai",
          205                 "Marc Simonetti",
          206                 "Mark Brooks",
          207                 "Michelangelo",
          208                 "Pablo Picasso",
          209                 "Paul Klee",
          210                 "Peter Mohrbacher",
          211                 "Pierre-Auguste Renoir",
          212                 "Pixar Animation Studios",
          213                 "Rembrandt",
          214                 "Richard Dadd",
          215                 "Rossdraws",
          216                 "Salvador Dalí",
          217                 "Sam Does Arts",
          218                 "Sandro Botticelli",
          219                 "Ted Nasmith",
          220                 "Ten Hundred",
          221                 "Thomas Kinkade",
          222                 "Tivadar Csontváry Kosztka",
          223                 "Victo Ngai",
          224                 "Vincent Di Fate",
          225                 "Vincent van Gogh",
          226                 "Wes Anderson",
          227                 "wlop",
          228                 "Yoshitaka Amano"
          229         ]
          230         style = random.choice(styles)
          231         modifier = random.sample(modifiers, random.randint(0, len(modifiers)))
          232         artist = random.choice(artists)
          233         time = random.choice(times)
          234         color = random.choice(colors)
          235         lighting = random.choice(lightnings)
          236         beauty = random.choice(beauties)
          237 
          238         etexta = []
          239         if beauty != None:
          240                 etexta.append(beauty)
          241         if time != None:
          242                 etexta.append(time)
          243         if style != None:
          244                 etexta.append(style)
          245         if text != None:
          246                 etexta.append(text)
          247         if background != None:
          248                 etexta.append("with")
          249                 etexta.append(background)
          250         if artist != None:
          251                 etexta.append("by")
          252                 etexta.append(artist)
          253         if len(modifier) > 0:
          254                 etexta.append(",")
          255                 modifiertext = ""
          256                 for m in modifier:
          257                         if m != None:
          258                                 if len(modifiertext) > 0:
          259                                         modifiertext += " "
          260                                 modifiertext += str(m)
          261                 etexta.append(modifiertext)
          262         if lighting != None:
          263                 etexta.append(",")
          264                 etexta.append(lighting)
          265         if color != None:
          266                 etexta.append(",")
          267                 etexta.append(color)
          268         etext = " ".join(etexta)
          269 
          270         return etext
          271 
          272 def usage(app):
          273         app = os.path.basename(app)
          274         print("usage: %s [-hft] [-c chan] [-d description] [-s sleept] YYYY-mm-dd" % (app),\
          275                         file=sys.stderr)
          276         sys.exit(1)
          277 
          278 def main(args):
          279         try:
          280                 opts, largs = getopt.getopt(args[1:], "h")
          281         except getopt.GetoptError as err:
          282                 print(str(err))
          283                 usage(args[0])
          284 
          285         for o, a in opts:
          286                 if o == "-h":
          287                         usage(args[0])
          288                 else:
          289                         assert False, "unhandled option"
          290 
          291         if len(largs) < 1:
          292                 usage(args[0])
          293 
          294         text = " ".join(largs)
          295         print(beautify_prompt(text))
          296         return 0
          297 
          298 if __name__ == "__main__":
          299         sys.exit(main(sys.argv))
          300