diff --git a/.gitignore b/.gitignore index e1172cd..654640b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pyc userfiles/antilist.csv +userfiles/config.csv \ No newline at end of file diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index a56d458..28bdd68 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -13,6 +13,11 @@ from random_functions import * 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): + # load the config file + config = load_config_csv() + + + # first build up a complete anti list. Those values are removing during list building # this uses the antivalues string AND the antilist.csv emptylist = [] @@ -145,12 +150,75 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all addontolocationinsidelist = [] addontolocationlist = [] - generatevehicle = bool(vehiclelist) - generateobject = bool(objectlist) - generatefood = bool(foodlist) - generatebuilding = bool(buildinglist) - generatespace = bool(spacelist) - generateobject = generatevehicle + generateobject + generatefood + generatebuilding + generatespace + # load subjects stuff from config + generatevehicle = False + generateobject = False + generatefood = False + generatebuilding = False + generatespace = False + generateanimal = False + generatemanwoman = False + generatemanwomanrelation = False + generatefictionalcharacter = False + generatenonfictionalcharacter = False + generatehumanoids = False + generatejob = False + generatelandscape = False + generateevent = False + generateconcepts = False + generatepoemline = False + generatesongline = False + + + for item in config: + # objects + if item[0] == 'subject_vehicle' and item[1] == 'on': + generatevehicle = True + if item[0] == 'subject_object' and item[1] == 'on': + generateobject = True + if item[0] == 'subject_food' and item[1] == 'on': + generatefood = True + if item[0] == 'subject_building' and item[1] == 'on': + generatebuilding = True + if item[0] == 'subject_space' and item[1] == 'on': + generatespace = True + # animals + if item[0] == 'subject_animal' and item[1] == 'on': + generateanimal = True + # humanoids + if item[0] == 'subject_manwoman' and item[1] == 'on': + generatemanwoman = True + if item[0] == 'subject_manwomanrelation' and item[1] == 'on': + generatemanwomanrelation = True + if item[0] == 'subject_fictional' and item[1] == 'on': + generatefictionalcharacter = True + if item[0] == 'subject_nonfictional' and item[1] == 'on': + generatenonfictionalcharacter = True + if item[0] == 'subject_humanoid' and item[1] == 'on': + generatehumanoids = True + if item[0] == 'subject_job' and item[1] == 'on': + generatejob = True + # landscape + if item[0] == 'subject_landscape' and item[1] == 'on': + generatelandscape = True + # concept + if item[0] == 'subject_event' and item[1] == 'on': + generateevent = True + if item[0] == 'subject_concept' and item[1] == 'on': + generateconcepts = True + if item[0] == 'poemline' and item[1] == 'on': + generatepoemline = True + if item[0] == 'songline' and item[1] == 'on': + generatesongline = True + + + + 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 + generateobject = generatevehicle or generateobject or generatefood or generatebuilding or generatespace if(generatevehicle): @@ -180,13 +248,13 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(generateobject): mainchooserlist.append("object") - generatefictionalcharacter = bool(fictionallist) - generatenonfictionalcharacter = bool(nonfictionallist) - generatehumanoids = bool(humanoidlist) - generatemanwoman = bool(manwomanlist) - generatemanwomanrelation = bool(manwomanrelationlist) - generatejob = bool(joblist) - generatehumanoid = generatefictionalcharacter + generatenonfictionalcharacter + generatehumanoids + generatemanwoman + generatejob + generatemanwomanrelation + 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 + generatejob = bool(joblist) and generatejob + generatehumanoid = generatefictionalcharacter or generatenonfictionalcharacter or generatehumanoids or generatemanwoman or generatejob or generatemanwomanrelation if(generatefictionalcharacter): @@ -217,23 +285,23 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all mainchooserlist.append("humanoid") - generateanimal = bool(animallist) + generateanimal = bool(animallist) and generateanimal if(generateanimal): mainchooserlist.append("animal") hybridlist.append("-animal-") - generatelandscape = bool(locationlist) + generatelandscape = bool(locationlist) and generatelandscape if(generatelandscape): mainchooserlist.append("landscape") addontolocationlist.append("-location-") addontolocationinsidelist.append("-location-") - generateevent = bool(eventlist) - generateconcepts = bool(conceptprefixlist) + bool(conceptsuffixlist) - generatepoemline = bool(poemlinelist) - generatesongline = bool(songlinelist) + generateevent = bool(eventlist) and generateevent + generateconcepts = bool(conceptprefixlist) and bool(conceptsuffixlist) and generateconcepts + generatepoemline = bool(poemlinelist) and generatepoemline + generatesongline = bool(songlinelist) and generatesongline diff --git a/csv_reader.py b/csv_reader.py index cccf27f..ffc146b 100644 --- a/csv_reader.py +++ b/csv_reader.py @@ -1,6 +1,7 @@ import csv import random import os +import shutil def random_read_from_csv(filename): script_dir = os.path.dirname(os.path.abspath(__file__)) # Script directory @@ -92,3 +93,21 @@ def artist_category_csv_to_list(csvfilename,category): +def load_config_csv(): + csvlist = [] + script_dir = os.path.dirname(os.path.abspath(__file__)) + full_path_config_file = os.path.join(script_dir, "./userfiles/" ) + full_path_default_config_file = os.path.join(script_dir, "./csvfiles/config/" ) + config_file = full_path_config_file + 'config.csv' + default_config_file = full_path_default_config_file + 'default_config.csv' + + if not os.path.exists(config_file): + shutil.copy2(default_config_file, config_file) + print("Config file created.") + + + with open(config_file, "r", newline="",encoding="utf8") as file: + reader = csv.DictReader(file, delimiter=";") + csvlist = [list(row.values()) for row in reader if not any(value.startswith('#') for value in row.values())] + return csvlist + \ No newline at end of file diff --git a/csvfiles/accessories.csv b/csvfiles/accessories.csv index e633cb8..bdbf360 100644 --- a/csvfiles/accessories.csv +++ b/csvfiles/accessories.csv @@ -26,6 +26,7 @@ Anime Eyes Hair Tie Hair Clip Hair Ribbons +Flower in hair Barrette Hat Trucker hat diff --git a/csvfiles/config/default_config.csv b/csvfiles/config/default_config.csv new file mode 100644 index 0000000..8f23610 --- /dev/null +++ b/csvfiles/config/default_config.csv @@ -0,0 +1,28 @@ +#this file controls the generation process; +#records starting with # are ignored; +#----; +# main subject generation options; +# these can either be on or off; +#----; +# objects; +subject_object;on +subject_vehicle;on +subject_food;on +subject_space;on +subject_building;on +# animals; +subject_animal;on +# humanoids; +subject_manwoman;on +subject_manwomanrelation;on +subject_fictional;on +subject_nonfictional;on +subject_humanoid;on +subject_job;on +# landscape; +subject_landscape;on +# concept; +subject_event;on +subject_concept;on +subject_poemline;on +subject_songline;on \ No newline at end of file diff --git a/csvfiles/containers.csv b/csvfiles/containers.csv index d203f90..b6b9608 100644 --- a/csvfiles/containers.csv +++ b/csvfiles/containers.csv @@ -23,4 +23,6 @@ Terrarium Fishbowl Paperweight Glass canister -Machine \ No newline at end of file +Machine +Glass case +Display case \ No newline at end of file diff --git a/csvfiles/elaborateoutfits.csv b/csvfiles/elaborateoutfits.csv index 37d5b53..7b34344 100644 --- a/csvfiles/elaborateoutfits.csv +++ b/csvfiles/elaborateoutfits.csv @@ -33,4 +33,5 @@ prehistoric -minioutfit-, in a cave, cave paintings, unga bunga cute cat ears, furry, kawaii, cutecore, happy, cattail, colorful cute -animal- ears, furry hybrid, grin, animal- tail, colorful F1 racer suit, at the pit stop, F1 car -Cargo Shorts, Tight Shirt and Vest, Adventuring Backpack Gear, Hiking Boots \ No newline at end of file +Cargo Shorts, Tight Shirt and Vest, Adventuring Backpack Gear, Hiking Boots +-rgpclass-, -minioutfit-, shield, sword, medieval \ No newline at end of file