Spaces:
Runtime error
Runtime error
Commit
•
5e721d2
0
Parent(s):
Duplicate from phenomenon1981/DreamlikeArt-Diffusion-1.0
Browse filesCo-authored-by: Dee Jay <phenomenon1981@users.noreply.huggingface.co>
- .gitattributes +34 -0
- README.md +19 -0
- app.py +155 -0
- requirements.txt +4 -0
- style.css +84 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: DreamlikeArt-Diffusion 1.0
|
3 |
+
emoji: 🧘🏻♂️
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.16.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: phenomenon1981/DreamlikeArt-Diffusion-1.0
|
11 |
+
---
|
12 |
+
---
|
13 |
+
title: DreamlikeArt-Diffusion .0
|
14 |
+
emoji: 🧘🏻♂️
|
15 |
+
colorFrom: blue
|
16 |
+
colorTo: yellow
|
17 |
+
sdk: gradio
|
18 |
+
sdk_version: 3.16.1
|
19 |
+
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import sys
|
4 |
+
from pathlib import Path
|
5 |
+
import random
|
6 |
+
import string
|
7 |
+
import time
|
8 |
+
from queue import Queue
|
9 |
+
from threading import Thread
|
10 |
+
import emoji
|
11 |
+
|
12 |
+
|
13 |
+
text_gen=gr.Interface.load("spaces/phenomenon1981/MagicPrompt-Stable-Diffusion")
|
14 |
+
def get_prompts(prompt_text):
|
15 |
+
if prompt_text:
|
16 |
+
return text_gen("dreamlikeart, " + prompt_text)
|
17 |
+
else:
|
18 |
+
return text_gen("")
|
19 |
+
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
20 |
+
|
21 |
+
def restart_script_periodically():
|
22 |
+
while True:
|
23 |
+
random_time = random.randint(540, 600)
|
24 |
+
time.sleep(random_time)
|
25 |
+
os.execl(sys.executable, sys.executable, *sys.argv)
|
26 |
+
|
27 |
+
|
28 |
+
restart_thread = Thread(target=restart_script_periodically, daemon=True)
|
29 |
+
restart_thread.start()
|
30 |
+
|
31 |
+
|
32 |
+
queue = Queue()
|
33 |
+
queue_threshold = 100
|
34 |
+
|
35 |
+
def add_random_noise(prompt, noise_level=0.00):
|
36 |
+
if noise_level == 0:
|
37 |
+
noise_level = 0.00
|
38 |
+
percentage_noise = noise_level * 5
|
39 |
+
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
40 |
+
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
41 |
+
prompt_list = list(prompt)
|
42 |
+
noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
|
43 |
+
noise_chars.extend(['😍', '💩', '😂', '🤔', '😊', '🤗', '😭', '🙄', '😷', '🤯', '🤫', '🥴', '😴', '🤩', '🥳', '😔', '😩', '🤪', '😇', '🤢', '😈', '👹', '👻', '🤖', '👽', '💀', '🎃', '🎅', '🎄', '🎁', '🎂', '🎉', '🎈', '🎊', '🎮', '❤️', '💔', '💕', '💖', '💗', '🐶', '🐱', '🐭', '🐹', '🦊', '🐻', '🐨', '🐯', '🦁', '🐘', '🔥', '🌧️', '🌞', '🌈', '💥', '🌴', '🌊', '🌺', '🌻', '🌸', '🎨', '🌅', '🌌', '☁️', '⛈️', '❄️', '☀️', '🌤️', '⛅️', '🌥️', '🌦️', '🌧️', '🌩️', '🌨️', '🌫️', '☔️', '🌬️', '💨', '🌪️', '🌈'])
|
44 |
+
for index in noise_indices:
|
45 |
+
prompt_list[index] = random.choice(noise_chars)
|
46 |
+
return "".join(prompt_list)
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
def send_it1(inputs, noise_level, proc1=proc1):
|
51 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
52 |
+
while queue.qsize() >= queue_threshold:
|
53 |
+
time.sleep(2)
|
54 |
+
queue.put(prompt_with_noise)
|
55 |
+
output1 = proc1(prompt_with_noise)
|
56 |
+
return output1
|
57 |
+
|
58 |
+
def send_it2(inputs, noise_level, proc1=proc1):
|
59 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
60 |
+
while queue.qsize() >= queue_threshold:
|
61 |
+
time.sleep(2)
|
62 |
+
queue.put(prompt_with_noise)
|
63 |
+
output2 = proc1(prompt_with_noise)
|
64 |
+
return output2
|
65 |
+
|
66 |
+
#def send_it3(inputs, noise_level, proc1=proc1):
|
67 |
+
#prompt_with_noise = add_random_noise(inputs, noise_level)
|
68 |
+
#while queue.qsize() >= queue_threshold:
|
69 |
+
#time.sleep(2)
|
70 |
+
#queue.put(prompt_with_noise)
|
71 |
+
#output3 = proc1(prompt_with_noise)
|
72 |
+
#return output3
|
73 |
+
|
74 |
+
#def send_it4(inputs, noise_level, proc1=proc1):
|
75 |
+
#prompt_with_noise = add_random_noise(inputs, noise_level)
|
76 |
+
#while queue.qsize() >= queue_threshold:
|
77 |
+
#time.sleep(2)
|
78 |
+
#queue.put(prompt_with_noise)
|
79 |
+
#output4 = proc1(prompt_with_noise)
|
80 |
+
#return output4
|
81 |
+
|
82 |
+
|
83 |
+
with gr.Blocks(css='style.css') as demo:
|
84 |
+
gr.HTML(
|
85 |
+
"""
|
86 |
+
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
87 |
+
<div>
|
88 |
+
<h1 style="font-weight: 900; font-size: 3rem; margin-bottom:20px;">
|
89 |
+
Dreamlike Diffusion 1.0
|
90 |
+
</h1>
|
91 |
+
</div>
|
92 |
+
<p style="margin-bottom: 10px; font-size: 96%">
|
93 |
+
Noise Level: Controls how much randomness is added to the input before it is sent to the model. Higher noise level produces more diverse outputs, while lower noise level produces similar outputs,
|
94 |
+
<a href="https://twitter.com/DavidJohnstonxx/">created by Phenomenon1981</a>.
|
95 |
+
</p>
|
96 |
+
<p style="margin-bottom: 10px; font-size: 98%">
|
97 |
+
❤️ Press the Like Button if you enjoy my space! ❤️</a>
|
98 |
+
</p>
|
99 |
+
</div>
|
100 |
+
"""
|
101 |
+
)
|
102 |
+
with gr.Column(elem_id="col-container"):
|
103 |
+
with gr.Row(variant="compact"):
|
104 |
+
input_text = gr.Textbox(
|
105 |
+
label="Short Prompt",
|
106 |
+
show_label=False,
|
107 |
+
max_lines=2,
|
108 |
+
placeholder="Enter a basic idea and click 'Magic Prompt'. Got no ideas? No problem, Simply just hit the magic button!",
|
109 |
+
).style(
|
110 |
+
container=False,
|
111 |
+
)
|
112 |
+
see_prompts = gr.Button("✨ Magic Prompt ✨").style(full_width=False)
|
113 |
+
|
114 |
+
|
115 |
+
with gr.Row(variant="compact"):
|
116 |
+
prompt = gr.Textbox(
|
117 |
+
label="Enter your prompt",
|
118 |
+
show_label=False,
|
119 |
+
max_lines=2,
|
120 |
+
placeholder="Full Prompt",
|
121 |
+
).style(
|
122 |
+
container=False,
|
123 |
+
)
|
124 |
+
run = gr.Button("Generate Images").style(full_width=False)
|
125 |
+
|
126 |
+
with gr.Row():
|
127 |
+
with gr.Row():
|
128 |
+
noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
|
129 |
+
with gr.Row():
|
130 |
+
with gr.Row():
|
131 |
+
output1=gr.Image(label="Dreamlike Diffusion 1.0",show_label=False)
|
132 |
+
output2=gr.Image(label="Dreamlike Diffusion 1.0",show_label=False)
|
133 |
+
|
134 |
+
|
135 |
+
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
136 |
+
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
|
137 |
+
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
138 |
+
|
139 |
+
|
140 |
+
with gr.Row():
|
141 |
+
gr.HTML(
|
142 |
+
"""
|
143 |
+
<div class="footer">
|
144 |
+
<p> Demo for <a href="https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0">Dreamlike Diffusion 1.0</a> Stable Diffusion model
|
145 |
+
</p>
|
146 |
+
</div>
|
147 |
+
<div class="acknowledgments" style="font-size: 115%">
|
148 |
+
<p> Unleash your creative side and generate mesmerizing images with just a few clicks! Enter a spark of inspiration in the "Basic Idea" text box and click the "Magic Prompt" button to elevate it to a polished masterpiece. Make any final tweaks in the "Full Prompt" box and hit the "Generate Images" button to watch your vision come to life. Experiment with the "Noise Level" for a diverse range of outputs, from similar to wildly unique. Let the fun begin!
|
149 |
+
</p>
|
150 |
+
</div>
|
151 |
+
"""
|
152 |
+
)
|
153 |
+
|
154 |
+
demo.launch(enable_queue=True, inline=True)
|
155 |
+
block.queue(concurrency_count=100)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
accelerate==0.12.0
|
2 |
+
gradio
|
3 |
+
xformers
|
4 |
+
emoji
|
style.css
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#col-container {
|
2 |
+
max-width: 800px;
|
3 |
+
margin-left: auto;
|
4 |
+
margin-right: auto;
|
5 |
+
}
|
6 |
+
a {
|
7 |
+
color: inherit;
|
8 |
+
text-decoration: underline;
|
9 |
+
}
|
10 |
+
.gradio-container {
|
11 |
+
font-family: 'IBM Plex Sans', sans-serif;
|
12 |
+
}
|
13 |
+
.gr-button {
|
14 |
+
color: white;
|
15 |
+
border-color: #9d66e5;
|
16 |
+
background: #9d66e5;
|
17 |
+
}
|
18 |
+
input[type='range'] {
|
19 |
+
accent-color: #9d66e5;
|
20 |
+
}
|
21 |
+
.dark input[type='range'] {
|
22 |
+
accent-color: #dfdfdf;
|
23 |
+
}
|
24 |
+
.container {
|
25 |
+
max-width: 800px;
|
26 |
+
margin: auto;
|
27 |
+
padding-top: 1.5rem;
|
28 |
+
}
|
29 |
+
#gallery {
|
30 |
+
min-height: 22rem;
|
31 |
+
margin-bottom: 15px;
|
32 |
+
margin-left: auto;
|
33 |
+
margin-right: auto;
|
34 |
+
border-bottom-right-radius: .5rem !important;
|
35 |
+
border-bottom-left-radius: .5rem !important;
|
36 |
+
}
|
37 |
+
#gallery>div>.h-full {
|
38 |
+
min-height: 20rem;
|
39 |
+
}
|
40 |
+
.details:hover {
|
41 |
+
text-decoration: underline;
|
42 |
+
}
|
43 |
+
.gr-button {
|
44 |
+
white-space: nowrap;
|
45 |
+
}
|
46 |
+
.gr-button:focus {
|
47 |
+
border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
48 |
+
outline: none;
|
49 |
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
50 |
+
--tw-border-opacity: 1;
|
51 |
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
52 |
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
|
53 |
+
--tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
|
54 |
+
--tw-ring-opacity: .5;
|
55 |
+
}
|
56 |
+
#advanced-options {
|
57 |
+
margin-bottom: 20px;
|
58 |
+
}
|
59 |
+
.footer {
|
60 |
+
margin-bottom: 45px;
|
61 |
+
margin-top: 35px;
|
62 |
+
text-align: center;
|
63 |
+
border-bottom: 1px solid #e5e5e5;
|
64 |
+
}
|
65 |
+
.footer>p {
|
66 |
+
font-size: .8rem;
|
67 |
+
display: inline-block;
|
68 |
+
padding: 0 10px;
|
69 |
+
transform: translateY(10px);
|
70 |
+
background: white;
|
71 |
+
}
|
72 |
+
.dark .logo{ filter: invert(1); }
|
73 |
+
.dark .footer {
|
74 |
+
border-color: #303030;
|
75 |
+
}
|
76 |
+
.dark .footer>p {
|
77 |
+
background: #0b0f19;
|
78 |
+
}
|
79 |
+
.acknowledgments h4{
|
80 |
+
margin: 1.25em 0 .25em 0;
|
81 |
+
font-weight: bold;
|
82 |
+
font-size: 115%;
|
83 |
+
}
|
84 |
+
|