Spaces:
Runtime error
Runtime error
Commit
•
c8f4a17
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 +196 -0
- requirements.txt +2 -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,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
queue = Queue()
|
10 |
+
|
11 |
+
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
12 |
+
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
13 |
+
proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
14 |
+
|
15 |
+
|
16 |
+
import random
|
17 |
+
|
18 |
+
def add_random_noise(prompt, noise_level=0.07):
|
19 |
+
# Get the percentage of characters to add as noise
|
20 |
+
percentage_noise = noise_level * 5
|
21 |
+
# Get the number of characters to add as noise
|
22 |
+
num_noise_chars = int(len(prompt) * (percentage_noise/100))
|
23 |
+
# Get the indices of the characters to add noise to
|
24 |
+
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
25 |
+
# Add noise to the selected characters
|
26 |
+
prompt_list = list(prompt)
|
27 |
+
for index in noise_indices:
|
28 |
+
prompt_list[index] = random.choice(string.ascii_letters + string.punctuation)
|
29 |
+
return "".join(prompt_list)
|
30 |
+
|
31 |
+
queue_length_counter = 0
|
32 |
+
|
33 |
+
def send_it1(inputs, noise_level, proc1=proc1):
|
34 |
+
global queue_length_counter
|
35 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
36 |
+
if queue_length_counter >= 15:
|
37 |
+
if not queue.empty():
|
38 |
+
queue.queue.clear()
|
39 |
+
queue_length_counter = 0
|
40 |
+
output1 = proc1(prompt_with_noise)
|
41 |
+
queue_length_counter += 1
|
42 |
+
time.sleep(3)
|
43 |
+
return output1
|
44 |
+
time.sleep(1)
|
45 |
+
|
46 |
+
def send_it2(inputs, noise_level, proc1=proc1):
|
47 |
+
global queue_length_counter
|
48 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
49 |
+
if queue_length_counter >= 15:
|
50 |
+
if not queue.empty():
|
51 |
+
queue.queue.clear()
|
52 |
+
queue_length_counter = 0
|
53 |
+
output2 = proc1(prompt_with_noise)
|
54 |
+
queue_length_counter += 1
|
55 |
+
time.sleep(3)
|
56 |
+
return output2
|
57 |
+
time.sleep(1)
|
58 |
+
|
59 |
+
def send_it3(inputs, noise_level, proc1=proc1):
|
60 |
+
global queue_length_counter
|
61 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
62 |
+
if queue_length_counter >= 15:
|
63 |
+
if not queue.empty():
|
64 |
+
queue.queue.clear()
|
65 |
+
queue_length_counter = 0
|
66 |
+
output3 = proc1(prompt_with_noise)
|
67 |
+
queue_length_counter += 1
|
68 |
+
time.sleep(3)
|
69 |
+
return output3
|
70 |
+
time.sleep(1)
|
71 |
+
|
72 |
+
def send_it4(inputs, noise_level, proc1=proc1):
|
73 |
+
global queue_length_counter
|
74 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
75 |
+
if queue_length_counter >= 15:
|
76 |
+
if not queue.empty():
|
77 |
+
queue.queue.clear()
|
78 |
+
queue_length_counter = 0
|
79 |
+
output4 = proc1(prompt_with_noise)
|
80 |
+
queue_length_counter += 1
|
81 |
+
time.sleep(3)
|
82 |
+
return output4
|
83 |
+
time.sleep(1)
|
84 |
+
|
85 |
+
def send_it5(inputs, noise_level, proc5=proc5):
|
86 |
+
global queue_length_counter
|
87 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
88 |
+
if queue_length_counter >= 15:
|
89 |
+
if not queue.empty():
|
90 |
+
queue.queue.clear()
|
91 |
+
queue_length_counter = 0
|
92 |
+
output5 = proc5(prompt_with_noise)
|
93 |
+
queue_length_counter += 1
|
94 |
+
time.sleep(3)
|
95 |
+
return output5
|
96 |
+
time.sleep(1)
|
97 |
+
|
98 |
+
def send_it6(inputs, noise_level, proc5=proc5):
|
99 |
+
global queue_length_counter
|
100 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
101 |
+
if queue_length_counter >= 15:
|
102 |
+
if not queue.empty():
|
103 |
+
queue.queue.clear()
|
104 |
+
queue_length_counter = 0
|
105 |
+
output6 = proc5(prompt_with_noise)
|
106 |
+
queue_length_counter += 1
|
107 |
+
time.sleep(3)
|
108 |
+
return output6
|
109 |
+
time.sleep(1)
|
110 |
+
|
111 |
+
def send_it7(inputs, noise_level, proc5=proc5):
|
112 |
+
global queue_length_counter
|
113 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
114 |
+
if queue_length_counter >= 15:
|
115 |
+
if not queue.empty():
|
116 |
+
queue.queue.clear()
|
117 |
+
queue_length_counter = 0
|
118 |
+
output7 = proc5(prompt_with_noise)
|
119 |
+
queue_length_counter += 1
|
120 |
+
time.sleep(3)
|
121 |
+
return output7
|
122 |
+
time.sleep(1)
|
123 |
+
|
124 |
+
def send_it8(inputs, noise_level, proc5=proc5):
|
125 |
+
global queue_length_counter
|
126 |
+
prompt_with_noise = add_random_noise(inputs, noise_level)
|
127 |
+
if queue_length_counter >= 15:
|
128 |
+
if not queue.empty():
|
129 |
+
queue.queue.clear()
|
130 |
+
queue_length_counter = 0
|
131 |
+
output8 = proc5(prompt_with_noise)
|
132 |
+
queue_length_counter += 1
|
133 |
+
time.sleep(3)
|
134 |
+
return output8
|
135 |
+
time.sleep(1)
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
def get_prompts(prompt_text):
|
140 |
+
global queue_length_counter
|
141 |
+
if queue_length_counter >= 15:
|
142 |
+
if not queue.empty():
|
143 |
+
queue.queue.clear()
|
144 |
+
queue_length_counter = 0
|
145 |
+
output = text_gen(prompt_text)
|
146 |
+
queue_length_counter += 1
|
147 |
+
time.sleep(3)
|
148 |
+
return output
|
149 |
+
time.sleep(1)
|
150 |
+
|
151 |
+
|
152 |
+
with gr.Blocks() as myface:
|
153 |
+
with gr.Row():
|
154 |
+
|
155 |
+
input_text=gr.Textbox(label="Short Prompt")
|
156 |
+
see_prompts=gr.Button("Magic Prompt")
|
157 |
+
with gr.Row():
|
158 |
+
|
159 |
+
prompt=gr.Textbox(label="Enter Prompt")
|
160 |
+
noise_level=gr.Slider(minimum=0.1, maximum=3, step=0.1, label="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.")
|
161 |
+
run=gr.Button("Generate")
|
162 |
+
|
163 |
+
with gr.Row():
|
164 |
+
like_message = gr.Button("❤️ Press the Like Button if you enjoy my space! ❤️")
|
165 |
+
with gr.Row():
|
166 |
+
output1=gr.Image(label="Dreamlike Photoreal 2.0")
|
167 |
+
output2=gr.Image(label="Dreamlike Photoreal 2.0")
|
168 |
+
with gr.Row():
|
169 |
+
output3=gr.Image(label="Dreamlike Photoreal 2.0")
|
170 |
+
output4=gr.Image(label="Dreamlike Photoreal 2.0")
|
171 |
+
with gr.Row():
|
172 |
+
output5=gr.Image(label="Dreamlike Diffusion 1.0")
|
173 |
+
output6=gr.Image(label="Dreamlike Diffusion 1.0")
|
174 |
+
with gr.Row():
|
175 |
+
output7=gr.Image(label="Dreamlike Diffusion 1.0")
|
176 |
+
output8=gr.Image(label="Dreamlike Diffusion 1.0")
|
177 |
+
|
178 |
+
|
179 |
+
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
|
180 |
+
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
181 |
+
run.click(send_it3, inputs=[prompt, noise_level], outputs=[output3])
|
182 |
+
run.click(send_it4, inputs=[prompt, noise_level], outputs=[output4])
|
183 |
+
run.click(send_it5, inputs=[prompt, noise_level], outputs=[output5])
|
184 |
+
run.click(send_it6, inputs=[prompt, noise_level], outputs=[output6])
|
185 |
+
run.click(send_it7, inputs=[prompt, noise_level], outputs=[output7])
|
186 |
+
run.click(send_it8, inputs=[prompt, noise_level], outputs=[output8])
|
187 |
+
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
|
188 |
+
|
189 |
+
|
190 |
+
|
191 |
+
myface.queue(concurrency_count=8)
|
192 |
+
myface.launch(enable_queue=True, inline=True)
|
193 |
+
while True:
|
194 |
+
if queue.qsize() >= 20:
|
195 |
+
queue.queue.clear()
|
196 |
+
time.sleep(30)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
accelerate==0.12.0
|
2 |
+
gradio
|