-
Notifications
You must be signed in to change notification settings - Fork 87
/
build_dynamic_prompt.py
5736 lines (4671 loc) · 295 KB
/
build_dynamic_prompt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import random
import re
if __package__ is None or __package__ == '':
# A1111 style (standalone script or direct module execution)
# Use absolute imports for compatibility with A1111 WebUI environment
from csv_reader import *
from random_functions import *
from one_button_presets import OneButtonPresets
from superprompter.superprompter import *
else:
# ComfyUI style (imported as a package)
# Use relative imports for proper integration with ComfyUI
from .csv_reader import *
from .random_functions import *
from .one_button_presets import OneButtonPresets
from .superprompter.superprompter import *
OBPresets = OneButtonPresets()
#builds a prompt dynamically
# insanity level controls randomness of propmt 0-10
# forcesubject van be used to force a certain type of subject
# Set artistmode to none, to exclude artists
def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all", imagetype = "all", onlyartists = False, antivalues = "", prefixprompt = "", suffixprompt ="",promptcompounderlevel ="1", seperator = "comma", givensubject="",smartsubject = True,giventypeofimage="", imagemodechance = 20, gender = "all", subtypeobject="all", subtypehumanoid="all", subtypeconcept="all", advancedprompting=True, hardturnoffemojis=False, seed=-1, overrideoutfit="", prompt_g_and_l = False, base_model = "SD1.5", OBP_preset = "", prompt_enhancer = "none", subtypeanimal="all", subtypelocation="all", preset_prefix = "", preset_suffix = ""):
remove_weights = False
less_verbose = False
add_vomit = True
add_quality = True
anime_mode = False
configfilesuffix = ""
if(forcesubject == "------ all"):
forcesubject = "all"
superprompter = False
prompt_enhancer = prompt_enhancer.lower()
if(prompt_enhancer == "superprompter" or prompt_enhancer == "superprompt" or prompt_enhancer == "superprompt-v1" or prompt_enhancer == "hyperprompt"):
superprompter = True
if(superprompter==True):
base_model = "Stable Cascade"
# new method of subject choosing from the interface, lets translate this:
subjectlist = translate_main_subject(forcesubject)
forcesubject = subjectlist[0]
# ugly but it works :D Keeps both methods working while the UI changes.
if(subtypeobject != "all" or subtypeobject != ""):
subtypeobject = subjectlist[1]
if(subtypeanimal != "all" or subtypeanimal != ""):
subtypeanimal = subjectlist[1]
if(subtypelocation != "all" or subtypelocation != ""):
subtypelocation = subjectlist[1]
if(subtypehumanoid != "all" or subtypehumanoid != ""):
subtypehumanoid = subjectlist[1]
if(subtypeconcept != "all" or subtypeconcept != ""):
subtypeconcept = subjectlist[1]
# set seed
# For use in ComfyUI (might bring to Automatic1111 as well)
# lets do it when its larger than 0
# Otherwise, just do nothing and it will keep on working based on an earlier set seed
if(seed > 0):
random.seed(seed)
originalinsanitylevel = insanitylevel
if(advancedprompting != False and random.randint(0,max(0, insanitylevel - 2)) <= 0):
advancedprompting == False
original_OBP_preset = OBP_preset
if(OBP_preset == OBPresets.RANDOM_PRESET_OBP):
obp_options = OBPresets.load_obp_presets()
random_preset = random.choice(list(obp_options.keys()))
print("Engaging randomized presets, locking on to: " + random_preset)
selected_opb_preset = OBPresets.get_obp_preset(random_preset)
insanitylevel = selected_opb_preset["insanitylevel"]
forcesubject = selected_opb_preset["subject"]
artists = selected_opb_preset["artist"]
subtypeobject = selected_opb_preset["chosensubjectsubtypeobject"]
subtypehumanoid = selected_opb_preset["chosensubjectsubtypehumanoid"]
subtypeconcept = selected_opb_preset["chosensubjectsubtypeconcept"]
gender = selected_opb_preset["chosengender"]
imagetype = selected_opb_preset["imagetype"]
imagemodechance = selected_opb_preset["imagemodechance"]
givensubject = selected_opb_preset["givensubject"]
smartsubject = selected_opb_preset["smartsubject"]
overrideoutfit = selected_opb_preset["givenoutfit"]
prefixprompt = selected_opb_preset["prefixprompt"]
suffixprompt = selected_opb_preset["suffixprompt"]
giventypeofimage = selected_opb_preset["giventypeofimage"]
antistring = selected_opb_preset["antistring"]
# api support tricks for OBP presets
OBP_preset = ""
if(OBP_preset != "" and OBP_preset != 'Custom...'):
selected_opb_preset = OBPresets.get_obp_preset(OBP_preset)
insanitylevel = selected_opb_preset["insanitylevel"]
forcesubject = selected_opb_preset["subject"]
artists = selected_opb_preset["artist"]
subtypeobject = selected_opb_preset["chosensubjectsubtypeobject"]
subtypehumanoid = selected_opb_preset["chosensubjectsubtypehumanoid"]
subtypeconcept = selected_opb_preset["chosensubjectsubtypeconcept"]
gender = selected_opb_preset["chosengender"]
imagetype = selected_opb_preset["imagetype"]
imagemodechance = selected_opb_preset["imagemodechance"]
givensubject = selected_opb_preset["givensubject"]
smartsubject = selected_opb_preset["smartsubject"]
overrideoutfit = selected_opb_preset["givenoutfit"]
prefixprompt = selected_opb_preset["prefixprompt"]
suffixprompt = selected_opb_preset["suffixprompt"]
giventypeofimage = selected_opb_preset["giventypeofimage"]
antistring = selected_opb_preset["antistring"]
prefixprompt = preset_prefix + ", " + prefixprompt
suffixprompt = suffixprompt + ", " + preset_suffix
# new method of subject choosing from the interface, lets translate this:
# really hacky way of doing this now.
if("-" in forcesubject):
subjectlist = translate_main_subject(forcesubject)
forcesubject = subjectlist[0]
# ugly but it works :D Keeps both methods working while the UI changes.
if(subtypeobject != "all" or subtypeobject != ""):
subtypeobject = subjectlist[1]
if(subtypeanimal != "all" or subtypeanimal != ""):
subtypeanimal = subjectlist[1]
if(subtypelocation != "all" or subtypelocation != ""):
subtypelocation = subjectlist[1]
if(subtypehumanoid != "all" or subtypehumanoid != ""):
subtypehumanoid = subjectlist[1]
if(subtypeconcept != "all" or subtypeconcept != ""):
subtypeconcept = subjectlist[1]
originalartistchoice = artists
doartistnormal = True
outfitmode = 0
animalashuman = False
partlystylemode = False
# cheat for presets
if(OBP_preset=='Waifu''s' or OBP_preset=='Husbando''s'):
basemodel = "Anime Model"
# Base model options, used to change things in prompt generation. Might be able to extend to different forms like animatediff as well?
base_model_options = ["SD1.5", "SDXL", "Stable Cascade", "Anime Model"]
if base_model not in base_model_options:
base_model = "SD1.5" # Just in case there is no option here.
# "SD1.5" -- Standard, future: More original style prompting
# "SDXL" -- Standard (for now), future: More natural language
# "Stable Cascade" -- Remove weights
if(base_model == "Stable Cascade"):
remove_weights = True
add_vomit = False
add_quality = False
if(base_model == "SD1.5"):
less_verbose = True
if(base_model == "Anime Model"):
less_verbose = True
advancedprompting = False
anime_mode = True
configfilesuffix = "anime"
# Hard overwrite some stuff because people dont config this themselves
if((anime_mode or imagetype == "all - anime") and (artists == "all" or normal_dist(insanitylevel))):
artists = "none"
# load the config file
config = load_config_csv(configfilesuffix)
# first build up a complete anti list. Those values are removing during list building
# this uses the antivalues string AND the antilist.csv
emptylist = []
antilist = csv_to_list("antilist",emptylist , "./userfiles/",1)
antivaluelist = antivalues.split(",")
antilist += antivaluelist
# clean up antivalue list:
antilist = [s.strip().lower() for s in antilist]
# Some tricks for gender to make sure we can choose Him/Her/It etc on the right time.
if(gender=="all"):
genderchoicelist = ["male", "female"]
gender = random.choice(genderchoicelist)
heshelist = ["it"]
hisherlist = ["its"]
himherlist = ["it"]
# we also need to oppositegender for some fun!
oppositegender = "male"
if(gender=="male"):
oppositegender = "female"
# build all lists here
colorlist = csv_to_list("colors",antilist)
animallist = csv_to_list("animals",antilist)
materiallist = csv_to_list("materials",antilist)
objectlist = csv_to_list("objects",antilist)
fictionallist = csv_to_list(csvfilename="fictional characters",antilist=antilist,skipheader=True,gender=gender)
nonfictionallist = csv_to_list(csvfilename="nonfictional characters",antilist=antilist,skipheader=True,gender=gender)
oppositefictionallist = csv_to_list(csvfilename="fictional characters",antilist=antilist,skipheader=True,gender=oppositegender)
oppositenonfictionallist = csv_to_list(csvfilename="nonfictional characters",antilist=antilist,skipheader=True,gender=oppositegender)
conceptsuffixlist = csv_to_list("concept_suffix",antilist)
buildinglist = csv_to_list("buildings",antilist)
vehiclelist = csv_to_list("vehicles",antilist)
outfitlist = csv_to_list("outfits",antilist)
locationlist = csv_to_list("locations",antilist)
backgroundlist = csv_to_list("backgrounds",antilist)
accessorielist = csv_to_list("accessories",antilist,"./csvfiles/",0,"?",False,False,gender)
artmovementlist = csv_to_list("artmovements",antilist)
bodytypelist = csv_to_list("body_types",antilist=antilist,skipheader=True,gender=gender)
cameralist = csv_to_list("cameras",antilist)
colorschemelist = csv_to_list("colorscheme",antilist)
conceptprefixlist = csv_to_list("concept_prefix",antilist)
culturelist = csv_to_list("cultures",antilist)
descriptorlist = csv_to_list("descriptors",antilist)
devmessagelist = csv_to_list("devmessages",antilist)
directionlist = csv_to_list(csvfilename="directions",antilist=antilist,insanitylevel=insanitylevel)
emojilist = csv_to_list("emojis",antilist)
eventlist = csv_to_list("events",antilist)
focuslist = csv_to_list(csvfilename="focus",antilist=antilist, insanitylevel=insanitylevel)
greatworklist = csv_to_list("greatworks",antilist)
haircolorlist = csv_to_list("haircolors",antilist)
hairstylelist = csv_to_list("hairstyles",antilist)
hairvomitlist = csv_to_list("hairvomit",antilist,"./csvfiles/",0,"?",False,False)
humanoidlist = csv_to_list("humanoids",antilist)
if(anime_mode or imagetype=="all - anime"):
if(imagetype == "all"):
imagetype = "all - anime"
imagetypelist = csv_to_list(csvfilename="imagetypes_anime",antilist=antilist, insanitylevel=insanitylevel, delimiter="?")
else:
imagetypelist = csv_to_list(csvfilename="imagetypes",antilist=antilist, insanitylevel=insanitylevel, delimiter="?")
joblist = csv_to_list(csvfilename="jobs",antilist=antilist,skipheader=True,gender=gender)
lenslist = csv_to_list(csvfilename="lenses",antilist=antilist, insanitylevel=insanitylevel)
lightinglist = csv_to_list(csvfilename="lighting",antilist=antilist, insanitylevel=insanitylevel)
malefemalelist = csv_to_list(csvfilename="malefemale",antilist=antilist,skipheader=True,gender=gender)
manwomanlist = csv_to_list(csvfilename="manwoman",antilist=antilist,skipheader=True,gender=gender)
moodlist = csv_to_list(csvfilename="moods",antilist=antilist, insanitylevel=insanitylevel)
othertypelist = csv_to_list("othertypes",antilist)
poselist = csv_to_list("poses",antilist)
qualitylist = csv_to_list("quality",antilist)
shotsizelist = csv_to_list(csvfilename="shotsizes",antilist=antilist, insanitylevel=insanitylevel)
timeperiodlist = csv_to_list("timeperiods",antilist)
vomitlist = csv_to_list(csvfilename="vomit",antilist=antilist, insanitylevel=insanitylevel)
if(anime_mode):
replacements = {
"-allstylessuffix-": "-buildfacepart-",
"-artistdescription-": "-buildfacepart-"
}
for i, item in enumerate(vomitlist):
for old, new in replacements.items():
item = item.replace(old, new)
vomitlist[i] = item
foodlist = csv_to_list("foods", antilist)
genderdescriptionlist = csv_to_list(csvfilename="genderdescription",antilist=antilist,skipheader=True,gender=gender)
minilocationlist = csv_to_list("minilocations", antilist)
minioutfitlist = csv_to_list("minioutfits",antilist,"./csvfiles/",0,"?",False,False,gender)
seasonlist = csv_to_list("seasons", antilist)
elaborateoutfitlist = csv_to_list("elaborateoutfits", antilist)
minivomitlist = csv_to_list("minivomit", antilist)
imagetypequalitylist = csv_to_list("imagetypequality", antilist)
rpgclasslist = csv_to_list("rpgclasses", antilist)
brandlist = csv_to_list("brands", antilist)
spacelist = csv_to_list("space", antilist)
poemlinelist = csv_to_list("poemlines", antilist)
songlinelist = csv_to_list("songlines", antilist)
musicgenrelist = csv_to_list("musicgenres", antilist)
manwomanrelationlist = csv_to_list(csvfilename="manwomanrelations",antilist=antilist,skipheader=True,gender=gender)
manwomanmultiplelist = csv_to_list(csvfilename="manwomanmultiples",antilist=antilist,skipheader=True,gender=gender,delimiter="?")
waterlocationlist = csv_to_list("waterlocations", antilist)
containerlist = csv_to_list("containers", antilist)
firstnamelist = csv_to_list(csvfilename="firstnames",antilist=antilist,skipheader=True,gender=gender)
floralist = csv_to_list("flora", antilist)
printlist = csv_to_list("prints", antilist)
patternlist = csv_to_list("patterns", antilist)
chairlist = csv_to_list("chairs", antilist)
cardnamelist = csv_to_list("card_names", antilist)
coveringlist = csv_to_list("coverings", antilist)
facepartlist = csv_to_list("faceparts", antilist)
outfitvomitlist = csv_to_list(csvfilename="outfitvomit",antilist=antilist,delimiter="?")
humanvomitlist = csv_to_list("humanvomit", antilist)
eyecolorlist = csv_to_list("eyecolors", antilist)
fashiondesignerlist = csv_to_list("fashiondesigners", antilist)
colorcombinationlist = csv_to_list("colorcombinations", antilist)
materialcombinationlist = csv_to_list("materialcombinations", antilist)
agelist = csv_to_list("ages", antilist)
agecalculatorlist = csv_to_list("agecalculator", antilist)
elementlist = csv_to_list("elements", antilist)
settinglist = csv_to_list("settings", antilist)
charactertypelist = csv_to_list("charactertypes", antilist)
objectstoholdlist = csv_to_list("objectstohold", antilist)
episodetitlelist = csv_to_list(csvfilename="episodetitles",antilist=antilist,skipheader=True)
flufferlist = csv_to_list("fluff", antilist)
tokenlist = []
# New set of lists
locationfantasylist = csv_to_list("locationsfantasy", antilist)
locationscifilist = csv_to_list("locationsscifi", antilist)
locationvideogamelist = csv_to_list("locationsvideogame", antilist)
locationbiomelist = csv_to_list("locationsbiome", antilist)
locationcitylist = csv_to_list("locationscities", antilist)
birdlist = csv_to_list("birds", antilist)
catlist = csv_to_list(csvfilename="cats", antilist=antilist,delimiter="?")
doglist = csv_to_list(csvfilename="dogs", antilist=antilist,delimiter="?")
insectlist = csv_to_list("insects", antilist)
pokemonlist = csv_to_list("pokemon", antilist)
pokemontypelist = csv_to_list("pokemontypes", antilist)
occultlist = csv_to_list("occult", antilist)
marinelifelist = csv_to_list("marinelife", antilist)
# additional descriptor lists
outfitdescriptorlist = csv_to_list("outfitdescriptors",antilist)
hairdescriptorlist = csv_to_list("hairdescriptors",antilist)
humandescriptorlist = csv_to_list("humandescriptors",antilist)
locationdescriptorlist = csv_to_list("locationdescriptors",antilist)
basicbitchdescriptorlist = csv_to_list("basicbitchdescriptors",antilist)
animaldescriptorlist = csv_to_list("animaldescriptors",antilist)
# descriptorlist becomes one with everything
descriptortotallist = descriptorlist + outfitdescriptorlist + hairdescriptorlist + humandescriptorlist + locationdescriptorlist + basicbitchdescriptorlist + animaldescriptorlist
# Deduplicate the list while preserving casings
descriptorlist = []
seen_items = set()
for item in descriptortotallist:
# Convert the item to lowercase to ignore casing
item_lower = item.lower()
if item_lower not in seen_items:
seen_items.add(item_lower)
descriptorlist.append(item)
humanlist = fictionallist + nonfictionallist + humanoidlist
objecttotallist = objectlist + buildinglist + vehiclelist + foodlist + spacelist + floralist + containerlist + occultlist
outfitprinttotallist = objecttotallist + locationlist + colorlist + musicgenrelist + seasonlist + animallist + patternlist
if(less_verbose):
humanactivitycheatinglist = ["-miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"-miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"-miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"-miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"-miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"-miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"-miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)"]
else:
humanactivitycheatinglist = ["OR(;, -heshe- is;uncommon) -miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"OR(;, -heshe- is;uncommon) -miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"OR(;, -heshe- is;uncommon) -miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"OR(;, -heshe- is;uncommon) -miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"OR(;, -heshe- is;uncommon) -miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"OR(;, -heshe- is;uncommon) -miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)",
"OR(;, -heshe- is;uncommon) -miniactivity- OR(in;at) a OR(-location-;-building-;-waterlocation-)"]
# build artists list
if artists == "wild":
artists = "all (wild)"
# we want to create more cohorence, so we are adding all (wild) mode for the old logic
# all else will be more constrained per type, to produce better images.
# the popular artists will be used more the lower the insanitylevel is
# Future: add in personal artists lists as well
# lets maybe go wild "sometimes", based on insanitylevel
if(artists == "all" and rare_dist(insanitylevel)):
artists = "all (wild)"
originalartistchoice = artists
artisttypes = ["popular", "3D", "abstract", "angular", "anime" ,"architecture", "art nouveau", "art deco", "baroque", "bauhaus", "cartoon", "character", "children's illustration", "cityscape", "cinema", "clean", "cloudscape", "collage", "colorful", "comics", "cubism", "dark", "detailed", "digital", "expressionism", "fantasy", "fashion", "fauvism", "figurativism", "graffiti", "graphic design", "high contrast", "horror", "impressionism", "installation", "landscape", "light", "line drawing", "low contrast", "luminism", "magical realism", "manga", "melanin", "messy", "monochromatic", "nature", "photography", "pop art", "portrait", "primitivism", "psychedelic", "realism", "renaissance", "romanticism", "scene", "sci-fi", "sculpture", "seascape", "space", "stained glass", "still life", "storybook realism", "street art", "streetscape", "surrealism", "symbolism", "textile", "ukiyo-e", "vibrant", "watercolor", "whimsical"]
artiststyleselector = ""
artiststyleselectormode = "normal"
if(artists == "all" and normal_dist(insanitylevel + 1)):
artiststyleselector = random.choice(artisttypes)
artists = artiststyleselector
elif(artists == "all"):
artiststyleselectormode = "custom"
# then else maybe do nothing??
if(random.randint(0,6) == 0 and onlyartists == False):
generateartist = False
# go popular! Or even worse, we go full greg mode!
elif(common_dist(max(3,insanitylevel))):
artists = "popular"
elif(random.randint(0,1) == 0):
# only on lower instanity levels anyway
if(insanitylevel < 6):
#too much greg mode!
artists = "greg mode"
else:
artists = "popular"
else:
artists = "none"
else:
artiststyleselectormode = "custom"
artistlist = []
# create artist list to use in the code, maybe based on category or personal lists
if(artists != "all (wild)" and artists != "all" and artists != "none" and artists.startswith("personal_artists") == False and artists.startswith("personal artists") == False and artists in artisttypes):
artistlist = artist_category_csv_to_list("artists_and_category",artists)
elif(artists.startswith("personal_artists") == True or artists.startswith("personal artists") == True):
artists = artists.replace(" ","_",-1) # add underscores back in
artistlist = csv_to_list(artists,antilist,"./userfiles/")
elif(artists != "none"):
artistlist = csv_to_list("artists",antilist)
# create special artists lists, used in templates
fantasyartistlist = artist_category_csv_to_list("artists_and_category","fantasy")
popularartistlist = artist_category_csv_to_list("artists_and_category","popular")
romanticismartistlist = artist_category_csv_to_list("artists_and_category","romanticism")
photographyartistlist = artist_category_csv_to_list("artists_and_category","photography")
portraitartistlist = artist_category_csv_to_list("artists_and_category","portrait")
characterartistlist = artist_category_csv_to_list("artists_and_category","character")
landscapeartistlist = artist_category_csv_to_list("artists_and_category","landscape")
scifiartistlist = artist_category_csv_to_list("artists_and_category","sci-fi")
graphicdesignartistlist = artist_category_csv_to_list("artists_and_category","graphic design")
digitalartistlist = artist_category_csv_to_list("artists_and_category","digital")
architectartistlist = artist_category_csv_to_list("artists_and_category","architecture")
cinemaartistlist = artist_category_csv_to_list("artists_and_category","cinema")
gregmodelist = csv_to_list("gregmode", antilist)
# add any other custom lists
stylestiloralist = csv_to_list("styles_ti_lora",antilist,"./userfiles/")
generatestyle = bool(stylestiloralist) # True of not empty
custominputprefixlist = csv_to_list("custom_input_prefix",antilist,"./userfiles/")
generatecustominputprefix = bool(custominputprefixlist) # True of not empty
custominputmidlist = csv_to_list("custom_input_mid",antilist,"./userfiles/")
generatecustominputmid = bool(custominputmidlist) # True of not empty
custominputsuffixlist = csv_to_list("custom_input_suffix",antilist,"./userfiles/")
generatecustominputsuffix = bool(custominputsuffixlist) # True of not empty
customsubjectslist = csv_to_list("custom_subjects",antilist,"./userfiles/")
customoutfitslist = csv_to_list("custom_outfits",antilist,"./userfiles/")
# special lists
backgroundtypelist = csv_to_list("backgroundtypes", antilist,"./csvfiles/special_lists/",0,"?")
insideshotlist = csv_to_list("insideshots", antilist,"./csvfiles/special_lists/",0,"?")
photoadditionlist = csv_to_list("photoadditions", antilist,"./csvfiles/special_lists/",0,"?")
if(less_verbose):
buildhairlist = csv_to_list("buildhair_less_verbose", antilist,"./csvfiles/special_lists/",0,"?")
buildoutfitlist = csv_to_list("buildoutfit_less_verbose", antilist,"./csvfiles/special_lists/",0,"?")
humanadditionlist = csv_to_list("humanadditions_less_verbose", antilist,"./csvfiles/special_lists/",0,"?")
objectadditionslist = csv_to_list("objectadditions_less_verbose", antilist,"./csvfiles/special_lists/",0,"?")
buildfacelist = csv_to_list("buildface_less_verbose", antilist,"./csvfiles/special_lists/",0,"?")
buildaccessorielist = csv_to_list("buildaccessorie_less_verbose", antilist,"./csvfiles/special_lists/",0,"?")
humanactivitylist = csv_to_list("human_activities_less_verbose",antilist,"./csvfiles/",0,"?",False,False)
humanexpressionlist = csv_to_list("humanexpressions_less_verbose",antilist,"./csvfiles/",0,"?",False,False)
else:
buildhairlist = csv_to_list("buildhair", antilist,"./csvfiles/special_lists/",0,"?")
buildoutfitlist = csv_to_list("buildoutfit", antilist,"./csvfiles/special_lists/",0,"?")
humanadditionlist = csv_to_list("humanadditions", antilist,"./csvfiles/special_lists/",0,"?")
objectadditionslist = csv_to_list("objectadditions", antilist,"./csvfiles/special_lists/",0,"?")
buildfacelist = csv_to_list("buildface", antilist,"./csvfiles/special_lists/",0,"?")
buildaccessorielist = csv_to_list("buildaccessorie", antilist,"./csvfiles/special_lists/",0,"?")
humanactivitylist = csv_to_list("human_activities",antilist,"./csvfiles/",0,"?",False,False)
humanexpressionlist = csv_to_list("humanexpressions",antilist,"./csvfiles/",0,"?",False,False)
humanactivitylist = humanactivitylist + humanactivitycheatinglist
animaladditionlist = csv_to_list("animaladditions", antilist,"./csvfiles/special_lists/",0,"?")
minilocationadditionslist = csv_to_list("minilocationadditions", antilist,"./csvfiles/special_lists/",0,"?")
overalladditionlist = csv_to_list("overalladditions", antilist,"./csvfiles/special_lists/",0,"?")
imagetypemodelist = csv_to_list("imagetypemodes", antilist,"./csvfiles/special_lists/",0,"?")
miniactivitylist = csv_to_list("miniactivity", antilist,"./csvfiles/special_lists/",0,"?")
animalsuffixadditionlist = csv_to_list("animalsuffixadditions", antilist,"./csvfiles/special_lists/",0,"?")
buildfacepartlist = csv_to_list("buildfaceparts", antilist,"./csvfiles/special_lists/",0,"?")
conceptmixerlist = csv_to_list("conceptmixer", antilist,"./csvfiles/special_lists/",0,"?")
tokinatorlist = csv_to_list("tokinator", antilist,"./csvfiles/templates/",0,"?")
styleslist = csv_to_list("styles", antilist,"./csvfiles/templates/",0,"?")
stylessuffix = [item.split('-subject-')[1] for item in styleslist]
breakstylessuffix = [item.split(',') for item in stylessuffix]
allstylessuffixlist = [value for sublist in breakstylessuffix for value in sublist]
allstylessuffixlist = list(set(allstylessuffixlist))
artistsuffix = artist_descriptions_csv_to_list("artists_and_category")
breakartiststylessuffix = [item.split(',') for item in artistsuffix]
artiststylessuffixlist = [value for sublist in breakartiststylessuffix for value in sublist]
artiststylessuffixlist = list(set(artiststylessuffixlist))
allstylessuffixlist += artiststylessuffixlist
dynamictemplatesprefixlist = csv_to_list("dynamic_templates_prefix", antilist,"./csvfiles/templates/",0,"?")
dynamictemplatessuffixlist = csv_to_list("dynamic_templates_suffix", antilist,"./csvfiles/templates/",0,"?")
# subjects
mainchooserlist = []
objectwildcardlist = []
locationwildcardlist = []
animalwildcardlist = []
hybridlist = []
hybridhumanlist = []
humanoidsubjectchooserlist = []
eventsubjectchooserlist = []
locationsubjectchooserlist = []
addontolocationinsidelist = []
addontolocationlist = []
# load subjects stuff from config
generatevehicle = True
generateobject = True
generatefood = True
generatebuilding = True
generatespace = True
generateflora = True
generateoccult = True
generateconcept = True
generateanimal = True
generatebird = True
generatecat = True
generatedog = True
generateinsect = True
generatepokemon = True
generatemarinelife = True
generatemanwoman = True
generatemanwomanrelation = True
generatemanwomanmultiple = True
generatefictionalcharacter = True
generatenonfictionalcharacter = True
generatehumanoids = True
generatejob = True
generatefirstnames = True
generatelandscape = True
generatelocation = True
generatelocationfantasy = True
generatelocationscifi = True
generatelocationvideogame = True
generatelocationbiome = True
generatelocationcity = True
generateevent = True
generateconcepts = True
generatepoemline = True
generatesongline = True
generatecardname = True
generateepisodetitle = True
custominputprefixrepeats = 2
custominputprefixchance = 'uncommon'
imagetypechance = 'normal'
generateimagetype = True
imagetypequalitychance = 'rare'
generateimagetypequality = True
generateminilocationaddition = True
minilocationadditionchance = 'unique'
artmovementprefixchance = 'unique'
minivomitprefix1chance = 'rare'
minivomitprefix2chance = 'unique'
shotsizechance = 'uncommon'
subjectdescriptor1chance = 'common'
subjectdescriptor2chance = 'uncommon'
subjectbodytypechance = 'normal'
subjectculturechance = 'normal'
subjectconceptsuffixchance = 'unique'
subjectlandscapeinsideshotchance = 'unique'
subjectlandscapeaddonlocationchance = 'normal'
subjectlandscapeaddonlocationdescriptorchance = 'rare'
subjectlandscapeaddonlocationculturechance = 'rare'
objectadditionsrepeats = 2
objectadditionschance = 'uncommon'
humanadditionchance = 'rare'
overalladditionchance = 'extraordinary'
emojichance = 'legendary'
buildfacechance = 'legendary'
humanexpressionchance = 'rare'
joboractivitychance = 'normal'
humanvomitchance = 'rare'
custominputmidrepeats = 2
custominputmidchance = 'uncommon'
minivomitmidchance = 'unique'
outfitchance = 'normal'
posechance = 'uncommon'
hairchance = 'normal'
accessorychance = 'normal'
humanoidinsideshotchance = 'legendary'
humanoidbackgroundchance = 'uncommon'
landscapeminilocationchance = 'uncommon'
generalminilocationchance = 'rare'
timperiodchance = 'normal'
focuschance = 'normal'
directionchance = 'normal'
moodchance = 'normal'
minivomitsuffixchance = 'unique'
artmovementchance = 'normal'
lightingchance = 'normal'
photoadditionchance = 'common'
lenschance = 'normal'
colorschemechance = 'normal'
vomit1chance = 'uncommon'
vomit2chance= 'uncommon'
greatworkchance = 'novel'
poemlinechance = 'novel'
songlinechance = 'novel'
quality1chance = 'uncommon'
quality2chance = 'uncommon'
customstyle1chance = 'uncommon'
customstyle2chance = 'uncommon'
custominputsuffixrepeats = 2
custominputsuffixchance = 'uncommon'
artistsatbackchance = 'uncommon'
for item in config:
# objects
if item[0] == 'subject_vehicle' and item[1] != 'on':
generatevehicle = False
if item[0] == 'subject_object' and item[1] != 'on':
generateobject = False
if item[0] == 'subject_food' and item[1] != 'on':
generatefood = False
if item[0] == 'subject_building' and item[1] != 'on':
generatebuilding = False
if item[0] == 'subject_space' and item[1] != 'on':
generatespace = False
if item[0] == 'subject_flora' and item[1] != 'on':
generateflora = False
if item[0] == 'subject_occult' and item[1] != 'on':
generateoccult = False
# animals
if item[0] == 'subject_animal' and item[1] != 'on':
generateanimal = False
if item[0] == 'subject_bird' and item[1] != 'on':
generatebird = False
if item[0] == 'subject_cat' and item[1] != 'on':
generatecat = False
if item[0] == 'subject_dog' and item[1] != 'on':
generatedog = False
if item[0] == 'subject_insect' and item[1] != 'on':
generateinsect = False
if item[0] == 'subject_pokemon' and item[1] != 'on':
generatepokemon = False
if item[0] == 'subject_marinelife' and item[1] != 'on':
generatemarinelife = False
# humanoids
if item[0] == 'subject_manwoman' and item[1] != 'on':
generatemanwoman = False
if item[0] == 'subject_manwomanrelation' and item[1] != 'on':
generatemanwomanrelation = False
if item[0] == 'subject_manwomanmultiple' and item[1] != 'on':
generatemanwomanmultiple = False
if item[0] == 'subject_fictional' and item[1] != 'on':
generatefictionalcharacter = False
if item[0] == 'subject_nonfictional' and item[1] != 'on':
generatenonfictionalcharacter = False
if item[0] == 'subject_humanoid' and item[1] != 'on':
generatehumanoids = False
if item[0] == 'subject_job' and item[1] != 'on':
generatejob = False
if item[0] == 'subject_firstnames' and item[1] != 'on':
generatefirstnames = False
# landscape
if item[0] == 'subject_location' and item[1] != 'on':
generatelocation = False
if item[0] == 'subject_location_fantasy' and item[1] != 'on':
generatelocationfantasy = False
if item[0] == 'subject_location_scifi' and item[1] != 'on':
generatelocationscifi = False
if item[0] == 'subject_location_videogame' and item[1] != 'on':
generatelocationvideogame = False
if item[0] == 'subject_location_biome' and item[1] != 'on':
generatelocationbiome = False
if item[0] == 'subject_location_city' and item[1] != 'on':
generatelocationcity = False
# concept
if item[0] == 'subject_event' and item[1] != 'on':
generateevent = False
if item[0] == 'subject_concept' and item[1] != 'on':
generateconcepts = False
if item[0] == 'subject_poemline' and item[1] != 'on':
generatepoemline = False
if item[0] == 'subject_songline' and item[1] != 'on':
generatesongline = False
if item[0] == 'subject_cardname' and item[1] != 'on':
generatecardname = False
if item[0] == 'subject_episodetitle' and item[1] != 'on':
generateepisodetitle = False
# main list stuff
if item[0] == 'custominputprefixrepeats':
custominputprefixrepeats = int(item[1])
if item[0] == 'custominputprefixchance':
custominputprefixchance = item[1]
if(custominputprefixchance == 'never'):
generatecustominputprefix = False
if item[0] == 'imagetypechance':
imagetypechance = item[1]
if(imagetypechance == 'never'):
generateimagetype = False
if item[0] == 'imagetypequalitychance':
imagetypequalitychance = item[1]
if(imagetypequalitychance == 'never'):
generateimagetypequality = False
if item[0] == 'minilocationadditionchance':
minilocationadditionchance = item[1]
if item[0] == 'artmovementprefixchance':
artmovementprefixchance = item[1]
if item[0] == 'minivomitprefix1chance':
minivomitprefix1chance = item[1]
if item[0] == 'minivomitprefix2chance':
minivomitprefix2chance = item[1]
if item[0] == 'shotsizechance':
shotsizechance = item[1]
if item[0] == 'subjectdescriptor1chance':
subjectdescriptor1chance = item[1]
if item[0] == 'subjectdescriptor2chance':
subjectdescriptor2chance = item[1]
if item[0] == 'subjectbodytypechance':
subjectbodytypechance = item[1]
if item[0] == 'subjectculturechance':
subjectculturechance = item[1]
if item[0] == 'subjectconceptsuffixchance':
subjectconceptsuffixchance = item[1]
if item[0] == 'subjectlandscapeinsideshotchance':
subjectlandscapeinsideshotchance = item[1]
if item[0] == 'subjectlandscapeaddonlocationchance':
subjectlandscapeaddonlocationchance = item[1]
if item[0] == 'subjectlandscapeaddonlocationdescriptorchance':
subjectlandscapeaddonlocationdescriptorchance = item[1]
if item[0] == 'subjectlandscapeaddonlocationculturechance':
subjectlandscapeaddonlocationculturechance = item[1]
if item[0] == 'objectadditionsrepeats':
objectadditionsrepeats = int(item[1])
if item[0] == 'objectadditionschance':
objectadditionschance = item[1]
if item[0] == 'humanadditionchance':
humanadditionchance = item[1]
if item[0] == 'overalladditionchance':
overalladditionchance = item[1]
if item[0] == 'emojichance':
emojichance = item[1]
if(hardturnoffemojis==True):
emojichance='never'
if item[0] == 'buildfacechance':
buildfacechance = item[1]
if item[0] == 'humanexpressionchance':
humanexpressionchance = item[1]
if item[0] == 'humanvomitchance':
humanvomitchance = item[1]
if item[0] == 'joboractivitychance':
joboractivitychance = item[1]
if item[0] == 'custominputmidrepeats':
custominputmidrepeats = int(item[1])
if item[0] == 'custominputmidchance':
custominputmidchance = item[1]
if item[0] == 'minivomitmidchance':
minivomitmidchance = item[1]
if item[0] == 'outfitchance':
outfitchance = item[1]
if item[0] == 'posechance':
posechance = item[1]
if item[0] == 'hairchance':
hairchance = item[1]
if item[0] == 'accessorychance':
accessorychance = item[1]
if item[0] == 'humanoidinsideshotchance':
humanoidinsideshotchance = item[1]
if item[0] == 'humanoidbackgroundchance':
humanoidbackgroundchance = item[1]
if item[0] == 'landscapeminilocationchance':
landscapeminilocationchance = item[1]
if item[0] == 'generalminilocationchance':
generalminilocationchance = item[1]
if item[0] == 'timperiodchance':
timperiodchance = item[1]
if item[0] == 'focuschance':
focuschance = item[1]
if item[0] == 'directionchance':
directionchance = item[1]
if item[0] == 'moodchance':
moodchance = item[1]
if item[0] == 'minivomitsuffixchance':
minivomitsuffixchance = item[1]
if item[0] == 'artmovementchance':
artmovementchance = item[1]
if item[0] == 'lightingchance':
lightingchance = item[1]
if item[0] == 'photoadditionchance':
photoadditionchance = item[1]
if item[0] == 'lenschance':
lenschance = item[1]
if item[0] == 'colorschemechance':
colorschemechance = item[1]
if item[0] == 'vomit1chance':
vomit1chance = item[1]
if item[0] == 'vomit2chance':
vomit2chance = item[1]
if item[0] == 'greatworkchance':
greatworkchance = item[1]
if item[0] == 'poemlinechance':
poemlinechance = item[1]
if item[0] == 'songlinechance':
songlinechance = item[1]
if item[0] == 'quality1chance':
quality1chance = item[1]
if item[0] == 'quality2chance':
quality2chance = item[1]
if item[0] == 'customstyle1chance':
customstyle1chance = item[1]
if item[0] == 'customstyle2chance':
customstyle2chance = item[1]
if item[0] == 'custominputsuffixrepeats':
custominputsuffixrepeats = int(item[1])
if item[0] == 'custominputsuffixchance':
custominputsuffixchance = item[1]
if item[0] == 'artistsatbackchance':
artistsatbackchance = item[1]
generatevehicle = bool(vehiclelist) and generatevehicle
generateobject = bool(objectlist) and generateobject
generatefood = bool(foodlist) and generatefood
generatebuilding = bool(buildinglist) and generatebuilding
generatespace = bool(spacelist) and generatespace
generateflora = bool(floralist) and generateflora
generateoccult = bool(occultlist) and generateoccult
generateobject = generatevehicle or generateobject or generatefood or generatebuilding or generatespace or generateflora or generateoccult
if(generatevehicle):
objectwildcardlist.append("-vehicle-")
hybridlist.append("-vehicle-")
addontolocationlist.append("-vehicle-")
if(generateobject):
objectwildcardlist.append("-object-")
hybridlist.append("-object-")
if(generatefood):
objectwildcardlist.append("-food-")
hybridlist.append("-food-")
if(generatespace):
objectwildcardlist.append("-space-")
hybridlist.append("-space-")
addontolocationlist.append("-space-")
if(generatebuilding):
objectwildcardlist.append("-building-")
hybridlist.append("-building-")
addontolocationlist.append("-building-")
addontolocationinsidelist.append("-building-")
if(generateflora):
objectwildcardlist.append("-flora-")
hybridlist.append("-flora-")
addontolocationlist.append("-flora-")
if(generateoccult):
objectwildcardlist.append("-occult-")
hybridlist.append("-occult-")
addontolocationlist.append("-occult-")
if(generateobject):
mainchooserlist.append("object")
if(generatelandscape):
mainchooserlist.append("landscape")
if(generatelocationfantasy):
locationwildcardlist.append("-locationfantasy-")
if(generatelocationscifi):
locationwildcardlist.append("-locationscifi-")
if(generatelocationvideogame):
locationwildcardlist.append("-locationvideogame-")
if(generatelocationbiome):
locationwildcardlist.append("-locationbiome-")
if(generatelocationcity):
locationwildcardlist.append("-locationcity-")
if(generatelocation):
locationwildcardlist.append("-location-")
if(generateanimal):
animalwildcardlist.append("-animal-")
if(generatebird):
animalwildcardlist.append("-bird-")
if(generatecat):
animalwildcardlist.append("-cat-")
if(generatedog):
animalwildcardlist.append("-dog-")
if(generateinsect):
animalwildcardlist.append("-insect-")
if(generatepokemon):
animalwildcardlist.append("-pokemon-")
if(generatemarinelife):
animalwildcardlist.append("-marinelife-")
generatefictionalcharacter = bool(fictionallist) and generatefictionalcharacter
generatenonfictionalcharacter = bool(nonfictionallist) and generatenonfictionalcharacter
generatehumanoids = bool(humanoidlist) and generatehumanoids
generatemanwoman = bool(manwomanlist) and generatemanwoman
generatemanwomanrelation = bool(manwomanrelationlist) and generatemanwomanrelation
generatemanwomanmultiple = bool(manwomanmultiplelist) and generatemanwomanmultiple
generatejob = bool(joblist) and generatejob
generatefirstnames = bool(firstnamelist) and generatefirstnames
generatehumanoid = generatefictionalcharacter or generatenonfictionalcharacter or generatehumanoids or generatemanwoman or generatejob or generatemanwomanrelation or generatefirstnames or generatemanwomanmultiple
if(generatefictionalcharacter):
humanoidsubjectchooserlist.append("fictional")
hybridlist.append("-fictional-")
hybridhumanlist.append("-fictional-")
if(generatefictionalcharacter):
humanoidsubjectchooserlist.append("non fictional")
hybridlist.append("-nonfictional-")
hybridhumanlist.append("-nonfictional-")
if(generatehumanoids):
humanoidsubjectchooserlist.append("humanoid")
hybridlist.append("-humanoid-")
hybridhumanlist.append("-humanoid-")
if(generatemanwoman):
humanoidsubjectchooserlist.append("human")
if(generatemanwomanrelation):
humanoidsubjectchooserlist.append("manwomanrelation")
if(generatemanwomanmultiple):
humanoidsubjectchooserlist.append("manwomanmultiple")
if(generatejob):
humanoidsubjectchooserlist.append("job")
if(generatehumanoid):
mainchooserlist.append("humanoid")
if(generatefirstnames):
humanoidsubjectchooserlist.append("firstname")