Spaces:
Runtime error
Runtime error
Commit
·
0837f13
1
Parent(s):
12d57be
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
from transformers import pipeline, set_seed
|
| 2 |
import gradio as grad, random, re
|
|
|
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
gpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')
|
|
@@ -29,23 +31,68 @@ def generate(starting_text):
|
|
| 29 |
if response_end != "":
|
| 30 |
return response_end
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline, set_seed
|
| 2 |
import gradio as grad, random, re
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
|
| 6 |
|
| 7 |
gpt2_pipe = pipeline('text-generation', model='Gustavosta/MagicPrompt-Stable-Diffusion', tokenizer='gpt2')
|
|
|
|
| 31 |
if response_end != "":
|
| 32 |
return response_end
|
| 33 |
|
| 34 |
+
with grad.Blocks(css='style.css') as demo:
|
| 35 |
+
grad.HTML(
|
| 36 |
+
"""
|
| 37 |
+
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
| 38 |
+
<div>
|
| 39 |
+
<h1 style="font-weight: 900; font-size: 3rem; margin-bottom:20px;">
|
| 40 |
+
The Stable Diffusion Prompt Generator - because your text needs a little more visual spice.
|
| 41 |
+
</h1>
|
| 42 |
+
</div>
|
| 43 |
+
<p style="margin-bottom: 10px; font-size: 96%">
|
| 44 |
+
Ready to see some magic happen? Simply type in your text. Feeling lazy? No problem, just hit the "Magic Prompt" button and it will randomly pull from a list of thousands of ideas for you.
|
| 45 |
+
</p>
|
| 46 |
+
<p style="margin-bottom: 10px; font-size: 98%">
|
| 47 |
+
❤️ Press the Like Button if you enjoy my space! ❤️</a>
|
| 48 |
+
</p>
|
| 49 |
+
</div>
|
| 50 |
+
"""
|
| 51 |
+
)
|
| 52 |
+
with grad.Column(elem_id="col-container"):
|
| 53 |
+
with grad.Row():
|
| 54 |
+
txt = grad.Textbox(
|
| 55 |
+
label="Initial Text",
|
| 56 |
+
show_label=False,
|
| 57 |
+
max_lines=1,
|
| 58 |
+
placeholder="Enter a basic idea",
|
| 59 |
+
).style(
|
| 60 |
+
container=False,
|
| 61 |
+
)
|
| 62 |
+
run = grad.Button("✨ Magic Prompt ✨").style(full_width=False)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
with grad.Row(variant="compact"):
|
| 67 |
+
out = grad.Textbox(
|
| 68 |
+
label="Generated Text",
|
| 69 |
+
show_label=False,
|
| 70 |
+
lines=5,
|
| 71 |
+
).style(
|
| 72 |
+
container=False,
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
run.click(generate, inputs=[txt], outputs=[out])
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
with grad.Row():
|
| 80 |
+
grad.HTML(
|
| 81 |
+
"""
|
| 82 |
+
<div class="footer">
|
| 83 |
+
<p> Powered by <a href="https://huggingface.co/Gustavosta">Gustavosta</a> Stable Diffusion model
|
| 84 |
+
</p>
|
| 85 |
+
</div>
|
| 86 |
+
<div class="acknowledgments" style="font-size: 115%">
|
| 87 |
+
<p> Transform your boring ideas into creative masterpieces with just one click! Enter a spark of inspiration and let the "Magic Prompt" button work its magic.
|
| 88 |
+
</p>
|
| 89 |
+
</div>
|
| 90 |
+
"""
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
fn=generate,
|
| 95 |
+
run=generate,
|
| 96 |
+
inputs=txt,
|
| 97 |
+
outputs=out
|
| 98 |
+
demo.launch(enable_queue=False, inline=True)
|