FoodDesert commited on
Commit
9c6cacb
1 Parent(s): ce85739

Upload 3 files

Browse files
Files changed (2) hide show
  1. SamplePrompts.csv +13 -0
  2. app.py +38 -22
SamplePrompts.csv ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Prompts:,,,,
2
+ name,source,description,prompt,negative
3
+ soyjak,drhead,simple prompt shows styles more intensely,"by artist, soyjak, anthro, male, bust portrait, meme, grin",
4
+ applejack,https://e621.net/posts/391069,"tags from a high-scoring image featuring a human, female, well-known character","by artist, applejack \(mlp\), human, mammal, alternate species, apple, black background, blonde hair, captain obvious, clothed, clothing, cowboy hat, eyebrows, eyelashes, female, food, freckles, front view, fruit, glistening, glistening body, glistening eyes, glistening hair, glistening skin, gloves, green eyes, hair, handwear, hat, headgear, headwear, holding food, holding object, human only, humanized, humor, long hair, looking aside, not furry, open mouth, orange clothing, pale skin, parody, pink tongue, plant, red apple, shadow, shirt, simple background, solo, teeth, tongue, topwear",nsfw
5
+ goat,https://e621.net/posts/2741820,tags from a high-scoring image featuring a male furry,"by artist, bovid, caprine, goat, mammal, angry, anthro, bar emanata, bell, bell collar, blush, child, collar, cowbell, daww, emanata, fur, hair, horizontal pupils, horn, male, nude, open mouth, orange eyes, pupils, red collar, simple background, solo, square pupils, tongue, unusual pupils, white body, white fur, white hair, young, young anthro",nsfw
6
+ pokemon,https://e621.net/posts/3744825,tags from a high-scoring image featuring a feral pokemon,"by artist, felid, feline, generation 9 pokemon, mammal, pokemon \(species\), sprigatito, :<, ambiguous gender, angry expression, bath, bathing, bathtub, bubble, bubble bath, daww, detailed background, dripping, feral, fur, green body, green fur, inside, multicolored body, multicolored fur, offscreen character, partially submerged, pupils, red eyes, shadow, slit pupils, solo, three-quarter view, two tone body, two tone fur, water, wet",nsfw
7
+ landscape,https://e621.net/posts/320878,tags from a landscape featuring no characters,"by artist, amazing background, cliff, cloud, crystal, detailed background, fantasy, forest, grass, high-angle view, horizon, landscape, monument, mountain, nature, not furry, outside, plant, plateau, river, rock, scenery, scenery porn, sculpture, sky, spikes, statue, tower, tree, water, waterfall, wood, zero pictured",nsfw
8
+ ,,,,
9
+ ,,,,
10
+ ,,,,
11
+ ,,,,
12
+ Artists,,,,
13
+ {by grypwolf|by evilymasterful|by domovoi lazaroth|by krazyelf|by bzeh|by harmarist|by doxy|by cervina7 \(artist\)|by nastycalamari|by tyroo|by secretly saucy|by siroc|by jrjresq|by stylusknight|by raccoondouglas|by furlana|by slimefur|by aycee|by ncs|by areye \(artist\)|by devo87|by youjomodoki|by qupostuv35|by seraziel|by juiceps|by dezz|by sligarthetiger|by scafen \(artist\)|by brolaren|by ro|by 0r0ch1|by zeta-haru|by glacierclear|by kluclew|by feretta|by the gentle giant|by pata|by raikissu|by f-r95|by wolfy-nail|by darkenstardragon|by tokifuji|by flamespitter|by twinkle-sez|by aennor|by dangpa|by twistedscarlett60|by neelix|by scruffythedeer|by frenky hw|by hladilnik|by quotefox|by w4g4|by ancesra|by tzarvolver|by wolflong|by katahane3|by saurian \(artist\)|by ittybittykittytittys|by km-15|by nawka|by utopianvee|by anchee|None|by darkgem|by joaoppereiraus|by kittydee|by monkeyspirit|by tailzkim|by sidnithefox|by killioma|by cyancapsule|by asnnonaka|by skidoo|by iwbitu|by shadman|by luccatoasty|by re-sublimity-kun|by hyilpi|by sepulte|by cumbread|by sususuigi|by r3drunner|by jailbird|by agitype01|by chikaretsu|by lonbluewolf|by rick griffin|by euyoshi89|by cold-blooded-twilight|by domasarts|by katarhein|by fivel|by nextel|by negger|by mcfli|by gekasso|by anglo|by securipun|by zeiro|by cocoline \(artist\)|by lizardlars|by sabrotiger|by dripponi|by krokobyaka|by type|by bastionshadowpaw|by amberpendant|by chromapan|by buta99|by demicoeur|by alfa995|by spuydjeks|by spirale|by shaolin bones|by seth-iova|by complextree|by freckles \(artist\)|by angiewolf|by glopossum|by aoizuri|by inuzu|by zourik|by manmosu marimo|by sijimmy456|by zummeng|by mleonheart|by macaronneko|by pache riggs|by kanashiipanda|by smileeeeeee|by sicklyhypnos|by diacordst|by haychel|by zawmg|by orionsmaniac \(artist\)|by vhkansfweer|by tsampikos|by johnfoxart|by zp92|by gammainks|by gerrkk|by aomori|by kionant|by kanel|by tattoorexy|by mcfan|by sepiruth|by clockhands|by carpetwurm|by capaoculta|by miles df|by sana!rpg|by carrot \(artist\)|by inno-sjoa|by raptoral|by thericegoat|by iriedono|by acstlu|by rov|by glitter trap boy|by redrusker|by ldr|by frumples|by nikraccoom|by mystikfox61|by haaru|by ketei|by somik|by zinfyu|by jinu|by zoyler|by rotten robbie|by nurinaki|by sincrescent|by bonnie bovine|by cooliehigh|by s1m|by dash ravo|by jakethegoat|by claweddrip|by 007delta|by jizoku|by personalami|by marblesoda|by dagasi|by chrysalisdraws|by marik azemus34|by nnecgrau|by atrolux|by slugbox|by imgonnaloveyou|by snowskau|by drmax|by lazysnout|by xennos|by oro97|by dark violet|by eternity-zinogre|by nepentz|by rysonanthrodog|by sigma x|by omega56|by letodoesart|by skully|by delki|by ratatooey|by codyblue-731|by honeycalamari|by saltyxodium|by fleet-foot|by ashraely|by cobaltsynapse|by edjit|by twang|by etheross|by chelodoy|by shinodage|by dlw|by twiren|by ssssnowy|by nikkibunn|by backsash|by syuro|by zaush|by skeleion|by chunie|by butterchalk|by loimu|by seibear|by r-mk|by cobalt snow|by braeburned|by eldiman|by einshelm|by trigaroo|by eto ya|by gewitter|by wizzikt|by hyattlen|by coffeesoda|by photonoko|by woolrool|by jarnqk|by nuzzo|by inu-sama|by ruaidri|by jishinu|by merrunz|by hioshiru|by thousandfoldfeathers|by desertkaiju|by kakhao|by xeono|by b-epon|by nexivian|by smiju|by captainzepto|by meesh|by catcouch|by sorc|by ajin|by rajii|by tofu froth|by sagaris uwu|by burgerkiss|by black-kitten|by kawfee|by lizet|by berseepon09|by sssonic2|by backlash91|by doomthewolf|by arbuzbudesh|by k 98|by picturd|by rayka|by soulcentinel|by adelaherz|by babywife|by stargazer|by elicitie|by rakisha|by kuroodod|by discordthege|by the-minuscule-task|by rainbowscreen|by skygracer|by lynncore|by itsunknownanon|by goonie-san|by kekitopu|by ultrabondagefairy|by mawmain|by hoodie \(artist\)|by truegrave9|by modca|by stoopix|by fumiko|by patto|by iskra|by the crab mage|by narse|by zero-sum|by digitoxici|by abesdrawings|by yuio|by zhanbow|by avante92|by hinar miler|by kikurage|by raaz|by romarom|by iztli|by unknown artist|by foxovh|by dimwitdog|by miso souperstar|by totesfleisch8|by keadonger|by piporete|by valkoinen|by jay-r|by thesecretcave|by smitty g|by pixelsketcher|by youwannaslap|by seff|by sicmop|by dragonfu|by magnetus|by chloe-dog|by alibi-cami|by bonifasko|by dankflank|by pakwan008|by deymos|by viejillox|by lysergide|by metal \(artist\)|by vader-san|by lockworkorange|by prsmrti|by halbean|by naive tabby|by shoutingisfun|by kiyosan|by daftpatriot|by gothbunnyboy|by anonymous artist|by hark|by phenyanyanya|by tsudamaku|by koorinezumi|by natoli|by jackaloo|by boo3|by tfancred|by nana gel|by reddragonkan|by flinters|by amegared|by markie|by nishi oxnard|by chrisandcompany|by triadfox|by dlrowdog|by hentai boy|by lizheru|by buzzer \(artist\)|by satsumalord|by pasaran|by foxfoxplz|by blpanda|by babystar|by yantaro keno|by renee-moonveil|by 9x9|by tombola1993|by raptor007|by chaostone|by cooner|by mt tg|by ficficponyfic|by sarcolopter|by azumaril|by dreadwolfclaw1990|by bigshow|by fierglief|by bobert|by zeriara|by mac-daddy|by dragmon|by jbond|by trevor-fox|by parclytaxel|by kusosensei|by gyrotech|by itoruna|by a.b. lust|by superbunnygt|by doneru|by box xod|by lefthighkick|by uniparasite|by malicekira|by mizzyam|by vrabo|by sacrificabominat|by zer0rebel4|by rikitoka|by karabiner|by fredryk phox|by mot|by rairai-no26-chu|by citrinelle|by jrvanesbroek|by makarimorph|by torakuta|by 1boshi|by skyelegs|by kanada|by darkdoomer|by smudge proof|by riorix|by kitchiki|by bristol|by fuze|by dirtyscoundrel|by foxball|by badumsquish|by ken sugimori|by lovelesskiax|by ricky hoffman|by buta5kawa|by roobin|by grumpy griffin creations|by mastergodai|by imperatorcaesar|by lagotrope|by ichthy0stega|by dark-moltres|by smutbooru|by deanwolfwood|by kamui shirow|by koraru-san|by foxenawolf|by caramelcraze|by date natsuku|by cotton \(artist\)|by catmonkshiro|by julius zimmerman|by hitec|by snow utamaru|by ottahz|by ryuko rose|by takagi kyou|by ka-samy|by ittybittyshark|by dynoex|by hatake|by kraken \(artist\)|by ruthredmane|by cybercat|by honesty \(artist\)|by freeze-pop88|by kinoshita-jiroh|by sobieniak|by viroveteruscy|by kelly hamilton|by pembrokewkorgi|by hinami|by kick \(artist\)|by train \(artist\)|by mind drive|by ayaka|by harpseal|by ukisudori|by inunoshippo|by sikai|by jamminbison|by artsy-theo|by marco fanjul|by wolfmalro|by positive wishes \(artist\)|by schwartzgeist|by utsuki maito|by bunnie love|by mulefoot|by chris goodwin|by poge jirushi|by thegreatmatsutzu|by sachiel 666|by inkyfrog|by dtalvi|by rorr|by fab3716|by rex equinox|by navitaserussirus|by rousemouse|by bitterplaguerat|by dannyg|by sbshouseofpancakes|by slb|by edgar rice burroughs|by doug winger|by maxime-jeanne|by rocket grunt \(artist\)|by usuario2 \(artist\)|by mauroz|by sailoranna|by tatwuyan|by tkc2021|by misterdonn|by tanutronik753 k|by namagakiokami|by emufu|by suishou0602|by macop|by bakukurara|by oogamikennta|by tigerlilylucky|by mike sherman|by snowfyre|by mylafox|by kitfox-crimson|by arania|by selinatc|by toshi \(artist\)|by mofuaki|by pokefound|by delirost|by galacticmichi|by doost|by trixythespiderfox|by darkmirage|by aogami|by meraence|by isolatedartest|by nottrevbe|by nsfwzhenya|by fourball|by manene|by trinity-fate62|by kilinah|by ingi|by latchk3y|by pochincoff|by welost|by skipsy|by bunnybits|by lunalei|by yousan|by kaynine|by honovy|by dream and nightmare|by wugi|by viskasunya|by faejunkie|by v-tal|by sabuky|by faeki|by kammi-lu|by foxes in love|by nightfaux|by virtyalfobo|by peculiart|by rika|by marsminer|by discreet user|by marshmallow-ears|by aeonspassed|by dreiker|by lyme-slyme|by punkypanda|by ponporio \(artist\)|by sonsasu|by kame 3|by pururing|by wbnsfwfactory|by bikupan|by bigdon1992|by lichfang|by bakemonoy|by b-ern|by merunyaa|by redishdragie|by lightsource|by enigi09|by hanuvo|by justmegabenewell|by thefuckingdevil|by minnosimmins|by qwertydragon|by fakeryway|by cotora|by ark warrior|by danomil|by avoid posting|by kostos art|by ratcha|by atryl|by fuf|by lvlirror|by theboogie|by nitani|by roly|by aer0 zer0|by hardyboy|by nozomyarts|by sinsquared|by cherrikissu|by asaneman|by tfzn|by hooves-art|by catsudon|by bigcozyorca|by mr.smile|by sinensian|by nukochi|by felino|by toto draw|by mytigertail|by arrwulf|by oselotti|by gorsha pendragon|by laser \(artist\)|by doesnotexist|by nekowuwu|by alanscampos|by el-loko|by compfive|by komdog|by magenta7|by milachu92|by serex|by bigdad|by aaron \(artist\)|by diadorin|by pig \(artist\)|by slickerwolf|by angstrom|by kihu|by ike marshall|by chalo|by furball \(artist\)|by lavenderpandy|by hunterramirez|by kloudmutt|by jerseydevil|by zi ran|by moreuselesssource|by ocaritna|by rukifox|by tggeko|by kiseff|by e254e|by princelykaden|by artdecade|by inuki|by prrrrrrmine|by chewycuticle|by haps|by senz|by argento|by daigaijin|by falcrus|by omari|by risenpaw|by satsukii|by lollipopcon|by ralek|by kyrosh|by tush|by reccand|by sindoll|by zerofox1000|by kaboozey|by somescrub|by yurusa|by limebreaker|by keffotin|by matemi|by uromatsu|by roadiesky|by saku1saya|by knightmoonlight98|by zerolativity|by winick-lim|by harnny|by girlsay|by sukebepanda|by sparrow \(artist\)|by amazinggwen|by slug \(artist\)|by smoothlabs|by eleacat|by replica \(artist\)|by thewill|by kevinsano|by feliscede|by james howard|by moki|by skylardoodles|by hyucaze|by lumineko|by conditional dnp},,,,
app.py CHANGED
@@ -18,6 +18,8 @@ import zipfile
18
  from PIL import Image
19
  import io
20
  import os
 
 
21
 
22
 
23
 
@@ -102,14 +104,12 @@ You can read more about TF-IDF on its [Wikipedia page](https://en.wikipedia.org/
102
 
103
  ## How do the sample images work?
104
 
105
- For each artist in the dataset, we generated a sample image with the model Fluffyrock Unleashed using the prompt "by artist, soyjak, anthro, male, bust portrait, meme, grin".
106
  The simplicity of the prompt, the the simplicty of the default style, and the recognizability of the character make it easier to understand how artist names affect generated image styles.
107
- The first image returned is a baseline, generated with the same prompt, but with no artist name.
108
  You should compare all the images to the first to see how the artist names affect the output.
109
-
110
- ## Why is the layout so messed up?
111
-
112
- I do not know how to resolve an issue with the Gallery. I shuffled all the components around so that it would be at the bottom and not interfere with anything else.
113
  """
114
 
115
 
@@ -194,22 +194,28 @@ with open("word_rating_probabilities.csv", 'r', newline='', encoding='utf-8') as
194
  nsfw_tags.add(word)
195
 
196
 
197
- soyjak_directory_path = 'artistsoyjaks'
198
- soyjak_json_file_path = os.path.join(soyjak_directory_path, 'artistsoyjaks.json')
199
- with open(soyjak_json_file_path, 'r') as json_file:
200
- soyjak_artist_to_file_map = json.load(json_file)
201
-
202
 
203
- def generate_artist_image_tuples(top_artists, image_directory=soyjak_directory_path):
 
 
 
 
 
 
 
 
 
 
 
204
  artist_image_tuples = []
205
  for artist in top_artists:
206
- filename = soyjak_artist_to_file_map.get(artist)
207
  if filename:
208
  image_path = os.path.join(image_directory, filename)
209
  if os.path.exists(image_path):
210
  artist_image_tuples.append((image_path, artist if artist else "No Artist"))
211
 
212
- return artist_image_tuples
213
 
214
 
215
  def clean_tag(tag):
@@ -423,6 +429,7 @@ def find_similar_tags(test_tags, similarity_weight, allow_nsfw_tags):
423
 
424
  return html_content # Return list of lists for Dataframe
425
 
 
426
  def find_similar_artists(new_tags_string, top_n, similarity_weight, allow_nsfw_tags):
427
  try:
428
  new_tags_string = new_tags_string.lower()
@@ -446,11 +453,16 @@ def find_similar_artists(new_tags_string, top_n, similarity_weight, allow_nsfw_t
446
  top_artists_str = "\n".join([f"{rank+1}. {artist[3:]} ({score:.4f})" for rank, (artist, score) in enumerate(top_artists)])
447
  dynamic_prompts_formatted_artists = "{" + "|".join([artist for artist, _ in top_artists]) + "}"
448
 
449
- image_gallery = generate_artist_image_tuples([''] + [name[3:] for name, _ in top_artists])
 
 
 
 
 
450
 
451
- return unseen_tags_data, top_artists_str, dynamic_prompts_formatted_artists, image_gallery
452
  except ParseError as e:
453
- return [], "Parse Error: Check for mismatched parentheses or something", "", None
454
 
455
 
456
  with gr.Blocks() as app:
@@ -469,14 +481,18 @@ with gr.Blocks() as app:
469
  dynamic_prompts = gr.Textbox(label="Dynamic Prompts Format", info="For if you're using the Automatic1111 webui (https://github.com/AUTOMATIC1111/stable-diffusion-webui) with the Dynamic Prompts extension activated (https://github.com/adieyal/sd-dynamic-prompts) and want to try them all individually.")
470
  with gr.Row():
471
  unseen_tags = gr.HTML(label="Unseen Tags")
472
- with gr.Row():
473
- styles = gr.Gallery(label="Styles", allow_preview=True, preview=True, container=True, rows=1, columns=11)
474
-
475
-
 
 
 
 
476
  submit_button.click(
477
  find_similar_artists,
478
  inputs=[image_tags, num_artists, similarity_weight, allow_nsfw],
479
- outputs=[unseen_tags, top_artists, dynamic_prompts, styles]
480
  )
481
 
482
  gr.Markdown(faq_content)
 
18
  from PIL import Image
19
  import io
20
  import os
21
+ import glob
22
+ import itertools
23
 
24
 
25
 
 
104
 
105
  ## How do the sample images work?
106
 
107
+ In the first row of galleries, for each artist in the dataset, we generated a sample image with the model Fluffyrock Unleashed using the prompt "by artist, soyjak, anthro, male, bust portrait, meme, grin" where "artist" is the name of an artist.
108
  The simplicity of the prompt, the the simplicty of the default style, and the recognizability of the character make it easier to understand how artist names affect generated image styles.
109
+ The image on the left captioned "No Artist" was generated with the same prompt, but with no artist name.
110
  You should compare all the images to the first to see how the artist names affect the output.
111
+ Each subsequent row of images was generated using the same process, but with a different prompt.
112
+ See SamplePrompts.csv for the list of prompts used and their descriptions.
 
 
113
  """
114
 
115
 
 
194
  nsfw_tags.add(word)
195
 
196
 
 
 
 
 
 
197
 
198
+ sample_images_directory_path = 'sampleimages'
199
+ def generate_artist_image_tuples(top_artists, image_directory):
200
+ json_files = glob.glob(f'{image_directory}/*.json')
201
+ json_file_path = json_files[0] if json_files else None
202
+ with open(json_file_path, 'r') as json_file:
203
+ artist_to_file_map = json.load(json_file)
204
+
205
+ filename = artist_to_file_map.get("")
206
+ image_path = os.path.join(image_directory, filename)
207
+ if os.path.exists(image_path):
208
+ baseline_tuple = [(image_path, "No Artist")]
209
+
210
  artist_image_tuples = []
211
  for artist in top_artists:
212
+ filename = artist_to_file_map.get(artist)
213
  if filename:
214
  image_path = os.path.join(image_directory, filename)
215
  if os.path.exists(image_path):
216
  artist_image_tuples.append((image_path, artist if artist else "No Artist"))
217
 
218
+ return baseline_tuple, artist_image_tuples
219
 
220
 
221
  def clean_tag(tag):
 
429
 
430
  return html_content # Return list of lists for Dataframe
431
 
432
+
433
  def find_similar_artists(new_tags_string, top_n, similarity_weight, allow_nsfw_tags):
434
  try:
435
  new_tags_string = new_tags_string.lower()
 
453
  top_artists_str = "\n".join([f"{rank+1}. {artist[3:]} ({score:.4f})" for rank, (artist, score) in enumerate(top_artists)])
454
  dynamic_prompts_formatted_artists = "{" + "|".join([artist for artist, _ in top_artists]) + "}"
455
 
456
+ image_galleries = []
457
+ for root, dirs, files in os.walk(sample_images_directory_path):
458
+ for name in dirs:
459
+ baseline, artists = generate_artist_image_tuples([name[3:] for name, _ in top_artists], os.path.join(root, name))
460
+ image_galleries.append(baseline) # Add baseline as its own gallery item
461
+ image_galleries.append(artists) # Extend the list with artist tuples
462
 
463
+ return (unseen_tags_data, top_artists_str, dynamic_prompts_formatted_artists, *image_galleries) #image_galleries[0], image_galleries[1] DOES work. Find a generic alternative.
464
  except ParseError as e:
465
+ return [], "Parse Error: Check for mismatched parentheses or something", "", None, None
466
 
467
 
468
  with gr.Blocks() as app:
 
481
  dynamic_prompts = gr.Textbox(label="Dynamic Prompts Format", info="For if you're using the Automatic1111 webui (https://github.com/AUTOMATIC1111/stable-diffusion-webui) with the Dynamic Prompts extension activated (https://github.com/adieyal/sd-dynamic-prompts) and want to try them all individually.")
482
  with gr.Row():
483
  unseen_tags = gr.HTML(label="Unseen Tags")
484
+ galleries = []
485
+ for root, dirs, files in os.walk(sample_images_directory_path):
486
+ for name in dirs:
487
+ with gr.Row():
488
+ baseline = gr.Gallery(container=True, rows=1, columns=1, height=420, scale=3)
489
+ styles = gr.Gallery(container=True, rows=2, columns=5, height=420, scale=8)
490
+ galleries.extend([baseline, styles])
491
+
492
  submit_button.click(
493
  find_similar_artists,
494
  inputs=[image_tags, num_artists, similarity_weight, allow_nsfw],
495
+ outputs=[unseen_tags, top_artists, dynamic_prompts] + galleries
496
  )
497
 
498
  gr.Markdown(faq_content)