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