testing more stuff and settings

This commit is contained in:
AIrjen
2024-03-29 08:46:36 +01:00
parent aa0f7f8624
commit bb63ebec91
3 changed files with 101 additions and 18 deletions
+89 -2
View File
@@ -3,6 +3,7 @@ import re
from csv_reader import *
from random_functions import *
from one_button_presets import OneButtonPresets
from superprompter.superprompter import *
OBPresets = OneButtonPresets()
@@ -18,6 +19,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
less_verbose = False
add_vomit = True
add_quality = True
if(superprompter==True):
base_model = "Stable Cascade"
# set seed
@@ -3265,10 +3268,13 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
prompt_g = cleanup(promptlist[1], advancedprompting, insanitylevel)
prompt_l = cleanup((promptlist[0] + ", " + promptlist[2]).replace("of a",""), advancedprompting, insanitylevel)
if("@@@" in completeprompt and superprompter == True):
load_models()
promptlist = completeprompt.split("@@@")
subjectprompt = cleanup(promptlist[1], advancedprompting, insanitylevel)
superpromptresult = one_button_superprompt(insanitylevel=insanitylevel, prompt=subjectprompt, seed=seed)
startprompt = cleanup(promptlist[0], advancedprompting, insanitylevel)
completeprompt = startprompt + ", " + subjectprompt
endprompt = cleanup(promptlist[2], advancedprompting, insanitylevel)
completeprompt = startprompt + ", " + superpromptresult + ", " + endprompt
elif(prompt_g_and_l == True):
prompt_g = completeprompt
prompt_l = completeprompt
@@ -4690,4 +4696,85 @@ def split_prompt_to_words(text):
totallist = list(set(filter(None, totallist)))
return totallist
return totallist
def one_button_superprompt(insanitylevel, prompt, seed):
temperature_lookup = {
1: 0.001,
2: 0.01,
3: 0.1,
4: 0.3,
5: 0.5,
6: 0.7,
7: 1.0,
8: 2.5,
9: 5.0,
10: 10.0
}
old_max_new_tokens_lookup = {
1: 40,
2: 45,
3: 50,
4: 70,
5: 80,
6: 95,
7: 105,
8: 125,
9: 150,
10: 255
}
max_new_tokens_lookup = {
1: 512,
2: 512,
3: 512,
4: 512,
5: 512,
6: 512,
7: 512,
8: 512,
9: 512,
10: 512
}
top_p_lookup = {
1: 0.5,
2: 0.7,
3: 1.0,
4: 1.5,
5: 2.0,
6: 3.0,
7: 4.0,
8: 5.5,
9: 7.0,
10: 15.0
}
for insanitylevel in range(1,10):
temperature = temperature_lookup.get(insanitylevel, 0.5)
max_new_tokens = max_new_tokens_lookup.get(insanitylevel, 75)
top_p = top_p_lookup.get(insanitylevel, 5.0)
question = "Expand the following prompt to add more detail: "
superpromptresult = answer(input_text=question + prompt, max_new_tokens=max_new_tokens, repetition_penalty=2.0, temperature=temperature, top_p=top_p, top_k=10, seed=seed)
print("orignal: " + prompt)
print("insanitylevel: " + str(insanitylevel))
print("")
print("complete superprompt: " + superpromptresult)
print("")
# Find the indices of the nearest period and comma
period_index = superpromptresult.rfind('.')
comma_index = superpromptresult.rfind(',')
# Determine the index to cut off the string
cut_off_index = max(period_index, comma_index)
# Cut off the string at the determined index
if cut_off_index != -1: # If either period or comma exists
superpromptresult = superpromptresult[:cut_off_index + 1] # Include the period or comma
else:
superpromptresult = superpromptresult # If neither period nor comma exists, keep the entire text
return superpromptresult
+10 -11
View File
@@ -29,16 +29,15 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im
else:
result = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, subtypeobject, subtypehumanoid, subtypeconcept, advancedprompting, hardturnoffemojis, seed, overrideoutfit, prompt_g_and_l, base_model, OBP_preset, superprompter)
if(superprompter):
load_models()
superpromptresult = answer(input_text=result, max_new_tokens=150, repetition_penalty=1.5, temperature=0.5, top_p=0.1, top_k=10, seed=seed)
superpromptresult = answer(input_text="Help me prompt this a little bit better and concise: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=0.5, top_p=0.1, top_k=10, seed=seed)
superpromptresult = answer(input_text="Remix these words into a sentence: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=0.5, top_p=0.1, top_k=10, seed=seed)
superpromptresult = answer(input_text="Remix these words into a sentence: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=5.0, top_p=5, top_k=1, seed=seed)
superpromptresult = answer(input_text="Make this more artful: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=5.0, top_p=5, top_k=1, seed=seed)
#if(superprompter):
# load_models()
# superpromptresult1 = answer(input_text=result, max_new_tokens=150, repetition_penalty=1.5, temperature=0.5, top_p=0.1, top_k=10, seed=seed)
# superpromptresult2 = answer(input_text="Help me prompt this a little bit better and concise: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=0.5, top_p=0.1, top_k=10, seed=seed)
# superpromptresult3 = answer(input_text="Make this more artful: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=5.0, top_p=5, top_k=1, seed=seed)
# superpromptresult4 = answer(input_text="Describe this for me please: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=5.0, top_p=5, top_k=1, seed=seed)
#unload_models()
print (result + " --- " + superpromptresult)
#print (result + " --- " + superpromptresult1 + " --- " + superpromptresult2 + " --- " + superpromptresult3 + " --- " + superpromptresult4)
print("")
print("loop " + str(steps))
@@ -108,7 +107,7 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im
print("All done!")
if __name__ == "__main__":
generateprompts(1,5
generateprompts(1,3
,"all" # subject
,"all" # artists
,"all" # image type "only other types", "only templates mode", "art blaster mode", "quality vomit mode", "color cannon mode", "unique art mode", "massive madness mode", "photo fantasy mode", "subject only mode", "fixed styles mode", "dynamic templates mode", "artify mode"
@@ -126,10 +125,10 @@ if __name__ == "__main__":
, "all" # concept types
, False # prompt switching
, True # Turn off emojis
, 25 # seed
, 8 # seed
, "" #outfit override
, False #prompt_g_and_l
, "Stable Cascade" #base model
, "SDXL" #base model
, "" #preset "All (random)..."
, True # superprompter
)
+2 -5
View File
@@ -1,9 +1,6 @@
#!/usr/bin/env python
import datetime
import os
import random
import tkinter as tk
from tkinter import scrolledtext, ttk
import torch
from transformers import T5Tokenizer, T5ForConditionalGeneration
from superprompter.download_models import download_models
@@ -61,7 +58,7 @@ def answer(input_text="", max_new_tokens=512, repetition_penalty=1.2, temperatur
dirty_text = tokenizer.decode(outputs[0])
text = dirty_text.replace("<pad>", "").replace("</s>", "").strip()
print("Temperature: {temperature}\nTop P: {top_p}\nTop K: {top_k}\nSeed: {seed}\nOutput:\n\n")
# print("Temperature: {temperature}\nTop P: {top_p}\nTop K: {top_k}\nSeed: {seed}\nOutput:\n\n")
print(text)
# print(text)
return text