Commit
·
6d56b12
1
Parent(s):
f069c5b
Update app.py
Browse files
app.py
CHANGED
@@ -2,25 +2,33 @@ import gradio as gr
|
|
2 |
import random
|
3 |
from time import time, ctime
|
4 |
|
5 |
-
def promptgen(choice, num):
|
6 |
t = time()
|
7 |
print(ctime(t))
|
8 |
|
9 |
if choice == "Prompt Generator v0.1(Better quality)":
|
10 |
-
prompt = open('
|
11 |
elif choice == "Prompt Generator v0.2(More tags)":
|
12 |
-
prompt = open('
|
13 |
|
14 |
if int(num) < 1 or int(num) > 20:
|
15 |
num = 10
|
|
|
|
|
|
|
16 |
|
17 |
vocab = len(prompt)
|
18 |
generated = []
|
|
|
19 |
while len(sorted(set(generated), key=lambda d: generated.index(d))) < num:
|
20 |
rand = random.randint(0, vocab)
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
demo = gr.Blocks()
|
26 |
|
@@ -45,9 +53,10 @@ with demo:
|
|
45 |
with gr.Column():
|
46 |
model_size = gr.Radio(["Prompt Generator v0.1(Better quality)", "Prompt Generator v0.2(More tags)"], label="Model Variant", value="Prompt Generator v0.1(Better quality)")
|
47 |
number = gr.Number(value="10", label="Num of tag (MAX 20)", show_label=True)
|
|
|
48 |
out = gr.Textbox(lines=4, label="Generated Prompts")
|
49 |
greet_btn = gr.Button("Generate")
|
50 |
-
greet_btn.click(fn=promptgen, inputs=[model_size, number], outputs=out)
|
51 |
gr.HTML(
|
52 |
"""
|
53 |
<div class="footer">
|
|
|
2 |
import random
|
3 |
from time import time, ctime
|
4 |
|
5 |
+
def promptgen(choice, num, artist):
|
6 |
t = time()
|
7 |
print(ctime(t))
|
8 |
|
9 |
if choice == "Prompt Generator v0.1(Better quality)":
|
10 |
+
prompt = open('pr1.txt').read().splitlines()
|
11 |
elif choice == "Prompt Generator v0.2(More tags)":
|
12 |
+
prompt = open('pr2.txt').read().splitlines()
|
13 |
|
14 |
if int(num) < 1 or int(num) > 20:
|
15 |
num = 10
|
16 |
+
|
17 |
+
if int(artist) < 0 or int(artist) > 40:
|
18 |
+
artist = 2
|
19 |
|
20 |
vocab = len(prompt)
|
21 |
generated = []
|
22 |
+
artists_num = 0
|
23 |
while len(sorted(set(generated), key=lambda d: generated.index(d))) < num:
|
24 |
rand = random.randint(0, vocab)
|
25 |
+
if prompt[rand-1].startswith('art by') and artists_num < artist:
|
26 |
+
artists_num +=1
|
27 |
+
generated.append(prompt[rand-1])
|
28 |
+
elif not prompt[rand-1].startswith('art by'):
|
29 |
+
generated.append(prompt[rand-1])
|
30 |
+
print(' '.join(set(generated)) + '\n')
|
31 |
+
return ' '.join(set(generated))
|
32 |
|
33 |
demo = gr.Blocks()
|
34 |
|
|
|
53 |
with gr.Column():
|
54 |
model_size = gr.Radio(["Prompt Generator v0.1(Better quality)", "Prompt Generator v0.2(More tags)"], label="Model Variant", value="Prompt Generator v0.1(Better quality)")
|
55 |
number = gr.Number(value="10", label="Num of tag (MAX 20)", show_label=True)
|
56 |
+
artist = gr.Number(value="2", label="Num of artist (Standart 2)", show_label=True)
|
57 |
out = gr.Textbox(lines=4, label="Generated Prompts")
|
58 |
greet_btn = gr.Button("Generate")
|
59 |
+
greet_btn.click(fn=promptgen, inputs=[model_size, number, artist], outputs=out)
|
60 |
gr.HTML(
|
61 |
"""
|
62 |
<div class="footer">
|