Spaces:
Running
Running
Gustavosta
commited on
Commit
•
8d0121d
1
Parent(s):
6af3a2a
Added ideas.txt [Test]
Browse files
app.py
CHANGED
@@ -3,18 +3,19 @@ import gradio as grad, random, re
|
|
3 |
|
4 |
|
5 |
gpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')
|
6 |
-
|
|
|
7 |
|
8 |
|
9 |
def generate(starting_text):
|
10 |
-
seed = random.randint(100,
|
11 |
set_seed(seed)
|
12 |
|
13 |
if starting_text == "":
|
14 |
-
starting_text: str = random.
|
15 |
starting_text: str = re.sub(r"[,:\-–.!;?_]", '', starting_text)
|
16 |
|
17 |
-
response = gpt2_pipe(starting_text, max_length=(len(starting_text) + random.randint(
|
18 |
response_list = []
|
19 |
for x in response:
|
20 |
resp = x['generated_text'].strip()
|
@@ -32,6 +33,10 @@ def generate(starting_text):
|
|
32 |
txt = grad.Textbox(lines=1, label="Initial Text", placeholder="English Text here")
|
33 |
out = grad.Textbox(lines=4, label="Generated Prompts")
|
34 |
|
|
|
|
|
|
|
|
|
35 |
title = "Stable Diffusion Prompt Generator"
|
36 |
description = 'This is a demo of the model series: "MagicPrompt", in this case, aimed at: "Stable Diffusion". To use it, simply submit your text or click on one of the examples. To learn more about the model, [click here](https://huggingface.co/Gustavosta/MagicPrompt-Stable-Diffusion).<br>'
|
37 |
|
|
|
3 |
|
4 |
|
5 |
gpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')
|
6 |
+
with open("ideas.txt", "r") as f:
|
7 |
+
line = f.readlines()
|
8 |
|
9 |
|
10 |
def generate(starting_text):
|
11 |
+
seed = random.randint(100, 1000000)
|
12 |
set_seed(seed)
|
13 |
|
14 |
if starting_text == "":
|
15 |
+
starting_text: str = line[random.randrange(0, len(line))].replace("\n", "").lower().capitalize()
|
16 |
starting_text: str = re.sub(r"[,:\-–.!;?_]", '', starting_text)
|
17 |
|
18 |
+
response = gpt2_pipe(starting_text, max_length=(len(starting_text) + random.randint(60, 90)), num_return_sequences=4)
|
19 |
response_list = []
|
20 |
for x in response:
|
21 |
resp = x['generated_text'].strip()
|
|
|
33 |
txt = grad.Textbox(lines=1, label="Initial Text", placeholder="English Text here")
|
34 |
out = grad.Textbox(lines=4, label="Generated Prompts")
|
35 |
|
36 |
+
examples = []
|
37 |
+
for x in range(8):
|
38 |
+
examples.append(line[random.randrange(0, len(line))].replace("\n", "").lower().capitalize())
|
39 |
+
|
40 |
title = "Stable Diffusion Prompt Generator"
|
41 |
description = 'This is a demo of the model series: "MagicPrompt", in this case, aimed at: "Stable Diffusion". To use it, simply submit your text or click on one of the examples. To learn more about the model, [click here](https://huggingface.co/Gustavosta/MagicPrompt-Stable-Diffusion).<br>'
|
42 |
|