First part of config is working

This commit is contained in:
AIrjen
2023-07-04 20:11:59 +02:00
parent a10b7c2ceb
commit dfbc30f15c
7 changed files with 141 additions and 21 deletions
+1
View File
@@ -1,3 +1,4 @@
*.pyc
userfiles/antilist.csv
userfiles/config.csv
+87 -19
View File
@@ -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
+19
View File
@@ -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
+1
View File
@@ -26,6 +26,7 @@ Anime Eyes
Hair Tie
Hair Clip
Hair Ribbons
Flower in hair
Barrette
Hat
Trucker hat
1 Beauty Marks
26 Hair Tie
27 Hair Clip
28 Hair Ribbons
29 Flower in hair
30 Barrette
31 Hat
32 Trucker hat
+28
View File
@@ -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
1 #this file controls the generation process
2 #records starting with # are ignored
3 #----
4 # main subject generation options
5 # these can either be on or off
6 #----
7 # objects
8 subject_object on
9 subject_vehicle on
10 subject_food on
11 subject_space on
12 subject_building on
13 # animals
14 subject_animal on
15 # humanoids
16 subject_manwoman on
17 subject_manwomanrelation on
18 subject_fictional on
19 subject_nonfictional on
20 subject_humanoid on
21 subject_job on
22 # landscape
23 subject_landscape on
24 # concept
25 subject_event on
26 subject_concept on
27 subject_poemline on
28 subject_songline on
+3 -1
View File
@@ -23,4 +23,6 @@ Terrarium
Fishbowl
Paperweight
Glass canister
Machine
Machine
Glass case
Display case
1 Bottle
23 Fishbowl
24 Paperweight
25 Glass canister
26 Machine
27 Glass case
28 Display case
+2 -1
View File
@@ -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
Cargo Shorts, Tight Shirt and Vest, Adventuring Backpack Gear, Hiking Boots
-rgpclass-, -minioutfit-, shield, sword, medieval
1 wizard -minioutfit- and wizard hat, background is wizard tower, -minilocationaddition-
33 cute cat ears, furry, kawaii, cutecore, happy, cattail, colorful
34 cute -animal- ears, furry hybrid, grin, animal- tail, colorful
35 F1 racer suit, at the pit stop, F1 car
36 Cargo Shorts, Tight Shirt and Vest, Adventuring Backpack Gear, Hiking Boots
37 -rgpclass-, -minioutfit-, shield, sword, medieval