Commit
·
90321c4
1
Parent(s):
f948f9e
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import random
|
| 3 |
from time import time, ctime
|
| 4 |
|
| 5 |
-
def
|
| 6 |
t = time()
|
| 7 |
print(ctime(t))
|
| 8 |
|
|
@@ -30,40 +30,6 @@ def promptgen2(choice, num, artist):
|
|
| 30 |
print(', '.join(set(generated)) + '\n')
|
| 31 |
return ', '.join(set(generated))
|
| 32 |
|
| 33 |
-
def promptgen(choice, num, artist):
|
| 34 |
-
try:
|
| 35 |
-
gen_prompt = open('gen_prompt.txt').read().splitlines()
|
| 36 |
-
except:
|
| 37 |
-
pass
|
| 38 |
-
t = time()
|
| 39 |
-
print(ctime(t))
|
| 40 |
-
|
| 41 |
-
if choice == "Prompt Generator v0.1(Better quality)":
|
| 42 |
-
prompt = open('pr1.txt').read().splitlines()
|
| 43 |
-
elif choice == "Prompt Generator v0.2(More tags)":
|
| 44 |
-
prompt = open('pr2.txt').read().splitlines()
|
| 45 |
-
|
| 46 |
-
if int(num) < 1 or int(num) > 20:
|
| 47 |
-
num = 10
|
| 48 |
-
|
| 49 |
-
if int(artist) < 0 or int(artist) > 40:
|
| 50 |
-
artist = 2
|
| 51 |
-
|
| 52 |
-
vocab = len(prompt)
|
| 53 |
-
generated = []
|
| 54 |
-
artists_num = 0
|
| 55 |
-
with open('gen_prompt.txt', 'w') as f:
|
| 56 |
-
while len(sorted(set(generated), key=lambda d: generated.index(d))) < num:
|
| 57 |
-
rand = random.randint(0, vocab)
|
| 58 |
-
if prompt[rand-1].startswith('art by') and artists_num < artist:
|
| 59 |
-
artists_num +=1
|
| 60 |
-
generated.append(prompt[rand-1])
|
| 61 |
-
elif not prompt[rand-1].startswith('art by'):
|
| 62 |
-
generated.append(prompt[rand-1])
|
| 63 |
-
print(', '.join(set(generated)) + '\n')
|
| 64 |
-
f.write(f"{str(ctime(t))} - {', '.join(set(generated))}")
|
| 65 |
-
return ', '.join(set(generated))
|
| 66 |
-
|
| 67 |
demo = gr.Blocks()
|
| 68 |
|
| 69 |
with demo:
|
|
|
|
| 2 |
import random
|
| 3 |
from time import time, ctime
|
| 4 |
|
| 5 |
+
def promptgen(choice, num, artist):
|
| 6 |
t = time()
|
| 7 |
print(ctime(t))
|
| 8 |
|
|
|
|
| 30 |
print(', '.join(set(generated)) + '\n')
|
| 31 |
return ', '.join(set(generated))
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
demo = gr.Blocks()
|
| 34 |
|
| 35 |
with demo:
|