Created
February 22, 2023 01:19
-
-
Save anotherjesse/503fd86238acaea942df5cdfd1d083c5 to your computer and use it in GitHub Desktop.
use clip interegator to create prompts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import random | |
db = {} | |
def get_data(kind, count=1): | |
if kind not in db: | |
with open("clip_interrogator/data/{}.txt".format(kind)) as f: | |
db[kind] = f.read().splitlines() | |
data = db[kind] | |
random.shuffle(data) | |
return data[:count] | |
def make_prompts(subject, count=100): | |
num = 0 | |
rv = [] | |
while num < 100: | |
medium = get_data("mediums", 1)[0] | |
prompt = f"{medium} of female {subject} " | |
#if random.random() < 0.5: | |
# prompt += "nude " | |
for m in get_data("movements", random.randint(1, 3)): | |
prompt += m + " " | |
prompt += "by " + ", ".join(get_data("artists", random.randint(1, 3))) | |
prompt += ", ".join(get_data("flavors", random.randint(0, 5))) | |
negative_prompt = ", ".join(get_data("negative", random.randint(0, 5))) | |
num_ouputs = random.randint(1, 4) | |
seed = random.randint(0, 100000) | |
scheduler = random.choice( | |
[ | |
"PNDM", | |
"KLMS", | |
"DDIM", | |
"K_EULER", | |
"K_EULER_ANCESTRAL", | |
"DPMSolverMultistep", | |
] | |
) | |
name = "asim_{}_{}".format(medium, num) | |
name = "".join(filter(str.isalnum, name)) | |
disable_safety_check = False | |
#disable_safety_check = random.random() < 0.5 | |
rv.append( | |
{ | |
"name": name, | |
"inputs": { | |
"prompt": prompt, | |
"negative_prompt": negative_prompt, | |
"num_outputs": num_ouputs, | |
"scheduler": scheduler, | |
"disable_safety_check": disable_safety_check, | |
"seed": seed, | |
}, | |
} | |
) | |
num += num_ouputs | |
return rv[:count] | |
prompt_list = make_prompts("asim", count=200) | |
prompts = json.dumps(prompt_list, indent=2) | |
print(prompts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment