Spaces:
Runtime error
Runtime error
Commit
•
7b68d3f
0
Parent(s):
Duplicate from phenomenon1981/DreamlikeArt-PhotoReal-2.0
Browse filesCo-authored-by: Dee Jay <[email protected]>
- .gitattributes +34 -0
- README.md +19 -0
- app.py +159 -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-PhotoReal 2.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-PhotoReal-2.0
|
11 |
+
---
|
12 |
+
---
|
13 |
+
title: DreamlikeArt-PhotoReal 2.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,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
14 |
+
text_gen=gr.Interface.load("spaces/phenomenon1981/MagicPrompt-Stable-Diffusion")
|
15 |
+
def get_prompts(prompt_text):
|
16 |
+
if prompt_text:
|
17 |
+
return text_gen("photo, " + prompt_text)
|
18 |
+
else:
|
19 |
+
return text_gen("")
|
20 |
+
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
21 |
+
|
22 |
+
def restart_script_periodically():
|
23 |
+
while True:
|
24 |
+
random_time = random.randint(540, 600)
|
25 |
+
time.sleep(random_time)
|
26 |
+
os.execl(sys.executable, sys.executable, *sys.argv)
|
27 |
+
|
28 |
+
|
29 |
+
restart_thread = Thread(target=restart_script_periodically, daemon=True)
|
30 |
+
restart_thread.start()
|
31 |
+
|
32 |
+
|
33 |
+
queue = Queue()
|
34 |
+
queue_threshold = 100
|
35 |
+
|
36 |
+
def add_random_noise(prompt, noise_level=0.00):
|
37 |
+
if noise_level == 0:
|
38 |
+
noise_level = 0.00
|
39 |
+
percentage_noise = noise_level * 5
|
40 |
+
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
41 |
+
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
42 |
+
prompt_list = list(prompt)
|
43 |
+
noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
|
44 |
+
noise_chars.extend(['😍', '💩', '😂', '🤔', '😊', '🤗', '😭', '🙄', '😷', '🤯', '🤫', '🥴', '😴', '🤩', '🥳', '😔', '😩', '🤪', '😇', '🤢', '😈', '👹', '👻', '🤖', '👽', '💀', '🎃', '🎅', '🎄', '🎁', '🎂', '🎉', '🎈', '🎊', '🎮', '❤️', '💔', '💕', '💖', '💗', '🐶', '🐱', '🐭', '🐹', '🦊', '🐻', '🐨', '🐯', '🦁', '🐘', '🔥', '🌧️', '🌞', '🌈', '💥', '🌴', '🌊', '🌺', '🌻', '🌸', '🎨', '🌅', '🌌', '☁️', '⛈️', '❄️', '☀️', '🌤️', '⛅️', '🌥️', '🌦️', '🌧️', '🌩️', '🌨️', '🌫️', '☔️', '🌬️', '💨', '🌪️', '🌈'])
|
45 |
+
for index in noise_indices:
|
46 |
+
prompt_list[index] = random.choice(noise_chars)
|
47 |
+
return "".join(prompt_list)
|
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 |
+
|
84 |
+
with gr.Blocks(css='style.css') as demo:
|
85 |
+
gr.HTML(
|
86 |
+
"""
|
87 |
+
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
88 |
+
<div>
|
89 |
+
<h1 style="font-weight: 900; font-size: 3rem; margin-bottom:20px;">
|
90 |
+
Dreamlike Photoreal 2.0
|
91 |
+
</h1>
|
92 |
+
</div>
|
93 |
+
<p style="margin-bottom: 10px; font-size: 96%">
|
94 |
+
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,
|
95 |
+
<a href="https://twitter.com/DavidJohnstonxx/">created by Phenomenon1981</a>.
|
96 |
+
</p>
|
97 |
+
<p style="margin-bottom: 10px; font-size: 98%">
|
98 |
+
❤️ Press the Like Button if you enjoy my space! ❤️</a>
|
99 |
+
</p>
|
100 |
+
</div>
|
101 |
+
"""
|
102 |
+
)
|
103 |
+
with gr.Column(elem_id="col-container"):
|
104 |
+
with gr.Row(variant="compact"):
|
105 |
+
input_text = gr.Textbox(
|
106 |
+
label="Short Prompt",
|
107 |
+
show_label=False,
|
108 |
+
max_lines=2,
|
109 |
+
placeholder="Enter a basic idea and click 'Magic Prompt'. Got no ideas? No problem, Simply just hit the magic button!",
|
110 |
+
).style(
|
111 |
+
container=False,
|
112 |
+
)
|
113 |
+
see_prompts = gr.Button("✨ Magic Prompt ✨").style(full_width=False)
|
114 |
+
|
115 |
+
|
116 |
+
with gr.Row(variant="compact"):
|
117 |
+
prompt = gr.Textbox(
|
118 |
+
label="Enter your prompt",
|
119 |
+
show_label=False,
|
120 |
+
max_lines=2,
|
121 |
+
placeholder="Full Prompt",
|
122 |
+
).style(
|
123 |
+
container=False,
|
124 |
+
)
|
125 |
+
run = gr.Button("Generate Images").style(full_width=False)
|
126 |
+
|
127 |
+
with gr.Row():
|
128 |
+
with gr.Row():
|
129 |
+
noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
|
130 |
+
with gr.Row():
|
131 |
+
with gr.Row():
|
132 |
+
output1=gr.Image(label="Dreamlike-photoreal-2.0",show_label=False)
|
133 |
+
output2=gr.Image(label="Dreamlike-photoreal-2.0",show_label=False)
|
134 |
+
|
135 |
+
#with gr.Row():
|
136 |
+
#output1=gr.Image()
|
137 |
+
|
138 |
+
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
139 |
+
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
|
140 |
+
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
141 |
+
|
142 |
+
|
143 |
+
|
144 |
+
with gr.Row():
|
145 |
+
gr.HTML(
|
146 |
+
"""
|
147 |
+
<div class="footer">
|
148 |
+
<p> Demo for <a href="https://huggingface.co/dreamlike-art/dreamlike-photoreal-2.0">Dreamlike Photoreal 2.0</a> Stable Diffusion model
|
149 |
+
</p>
|
150 |
+
</div>
|
151 |
+
<div class="acknowledgments" style="font-size: 115%">
|
152 |
+
<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!
|
153 |
+
</p>
|
154 |
+
</div>
|
155 |
+
"""
|
156 |
+
)
|
157 |
+
|
158 |
+
demo.launch(enable_queue=True, inline=True)
|
159 |
+
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 |
+
|