Spaces:
Runtime error
Runtime error
Commit ·
90321c4
1
Parent(s): f948f9e
Update app.py
Browse files1 unmodified line234567821 unmodified lines303132333435363738394041424344454647484950515253545556575859606162636465666768691 unmodified lineimport randomfrom time import time, ctimedef promptgen2(choice, num, artist):t = time()print(ctime(t))21 unmodified linesprint(', '.join(set(generated)) + '\n')return ', '.join(set(generated))def promptgen(choice, num, artist):try:gen_prompt = open('gen_prompt.txt').read().splitlines()except:passt = time()print(ctime(t))if choice == "Prompt Generator v0.1(Better quality)":prompt = open('pr1.txt').read().splitlines()elif choice == "Prompt Generator v0.2(More tags)":prompt = open('pr2.txt').read().splitlines()if int(num) < 1 or int(num) > 20:num = 10if int(artist) < 0 or int(artist) > 40:artist = 2vocab = len(prompt)generated = []artists_num = 0with open('gen_prompt.txt', 'w') as f:while len(sorted(set(generated), key=lambda d: generated.index(d))) < num:rand = random.randint(0, vocab)if prompt[rand-1].startswith('art by') and artists_num < artist:artists_num +=1generated.append(prompt[rand-1])elif not prompt[rand-1].startswith('art by'):generated.append(prompt[rand-1])print(', '.join(set(generated)) + '\n')f.write(f"{str(ctime(t))} - {', '.join(set(generated))}")return ', '.join(set(generated))demo = gr.Blocks()with demo:1 unmodified line234567821 unmodified lines3031323334351 unmodified lineimport randomfrom time import time, ctimedef promptgen(choice, num, artist):t = time()print(ctime(t))21 unmodified linesprint(', '.join(set(generated)) + '\n')return ', '.join(set(generated))demo = gr.Blocks()with demo:
app.py+1-35