Spaces:
Runtime error
Runtime error
phenomenon1981
commited on
Commit
·
39c5681
1
Parent(s):
6550949
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ restart_thread = Thread(target=restart_script_periodically, daemon=True)
|
|
26 |
restart_thread.start()
|
27 |
|
28 |
queue = Queue()
|
29 |
-
queue_threshold =
|
30 |
|
31 |
def add_random_noise(prompt, noise_level=0.07):
|
32 |
# Get the percentage of characters to add as noise
|
@@ -48,25 +48,36 @@ def send_it1(inputs, noise_level, proc1=proc1):
|
|
48 |
while queue.qsize() >= queue_threshold:
|
49 |
time.sleep(2)
|
50 |
queue.put(prompt_with_noise)
|
51 |
-
time.
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
def send_it2(inputs, noise_level, proc1=proc1):
|
56 |
prompt_with_noise = add_random_noise(inputs, noise_level)
|
57 |
while queue.qsize() >= queue_threshold:
|
58 |
time.sleep(2)
|
59 |
queue.put(prompt_with_noise)
|
60 |
-
time.
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
def send_it3(inputs, noise_level, proc1=proc1):
|
65 |
prompt_with_noise = add_random_noise(inputs, noise_level)
|
66 |
while queue.qsize() >= queue_threshold:
|
67 |
time.sleep(2)
|
68 |
queue.put(prompt_with_noise)
|
69 |
-
time.sleep(10)
|
70 |
output3 = proc1(prompt_with_noise)
|
71 |
return output3
|
72 |
|
@@ -75,7 +86,6 @@ def send_it4(inputs, noise_level, proc1=proc1):
|
|
75 |
while queue.qsize() >= queue_threshold:
|
76 |
time.sleep(2)
|
77 |
queue.put(prompt_with_noise)
|
78 |
-
time.sleep(10)
|
79 |
output4 = proc1(prompt_with_noise)
|
80 |
return output4
|
81 |
|
@@ -84,7 +94,6 @@ def send_it5(inputs, noise_level, proc1=proc1):
|
|
84 |
while queue.qsize() >= queue_threshold:
|
85 |
time.sleep(2)
|
86 |
queue.put(prompt_with_noise)
|
87 |
-
time.sleep(10)
|
88 |
output5 = proc1(prompt_with_noise)
|
89 |
return output5
|
90 |
|
@@ -93,7 +102,6 @@ def send_it6(inputs, noise_level, proc1=proc1):
|
|
93 |
while queue.qsize() >= queue_threshold:
|
94 |
time.sleep(2)
|
95 |
queue.put(prompt_with_noise)
|
96 |
-
time.sleep(10)
|
97 |
output6 = proc1(prompt_with_noise)
|
98 |
return output6
|
99 |
|
@@ -102,7 +110,6 @@ def send_it7(inputs, noise_level, proc1=proc1):
|
|
102 |
while queue.qsize() >= queue_threshold:
|
103 |
time.sleep(2)
|
104 |
queue.put(prompt_with_noise)
|
105 |
-
time.sleep(10)
|
106 |
output7 = proc1(prompt_with_noise)
|
107 |
return output7
|
108 |
|
@@ -111,7 +118,6 @@ def send_it8(inputs, noise_level, proc1=proc1):
|
|
111 |
while queue.qsize() >= queue_threshold:
|
112 |
time.sleep(2)
|
113 |
queue.put(prompt_with_noise)
|
114 |
-
time.sleep(10)
|
115 |
output8 = proc1(prompt_with_noise)
|
116 |
return output8
|
117 |
|
@@ -145,14 +151,14 @@ with gr.Blocks() as myface:
|
|
145 |
output8=gr.Image(label="Dreamlike-photoreal-2.0")
|
146 |
|
147 |
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
148 |
-
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1]
|
149 |
-
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2]
|
150 |
-
run.click(send_it3, inputs=[prompt, noise_level], outputs=[output3]
|
151 |
-
run.click(send_it4, inputs=[prompt, noise_level], outputs=[output4]
|
152 |
-
run.click(send_it5, inputs=[prompt, noise_level], outputs=[output5]
|
153 |
-
run.click(send_it6, inputs=[prompt, noise_level], outputs=[output6]
|
154 |
-
run.click(send_it7, inputs=[prompt, noise_level], outputs=[output7]
|
155 |
-
run.click(send_it8, inputs=[prompt, noise_level], outputs=[output8]
|
156 |
|
157 |
myface.launch(enable_queue=True, inline=True)
|
158 |
block.queue(concurrency_count=100)
|
|
|
26 |
restart_thread.start()
|
27 |
|
28 |
queue = Queue()
|
29 |
+
queue_threshold = 800
|
30 |
|
31 |
def add_random_noise(prompt, noise_level=0.07):
|
32 |
# Get the percentage of characters to add as noise
|
|
|
48 |
while queue.qsize() >= queue_threshold:
|
49 |
time.sleep(2)
|
50 |
queue.put(prompt_with_noise)
|
51 |
+
start_time = time.time()
|
52 |
+
while True:
|
53 |
+
try:
|
54 |
+
output1 = proc1(prompt_with_noise)
|
55 |
+
return output1
|
56 |
+
except:
|
57 |
+
if time.time() - start_time > 20:
|
58 |
+
return "Error: Image generation took too long. Please try again."
|
59 |
+
time.sleep(1)
|
60 |
|
61 |
def send_it2(inputs, noise_level, proc1=proc1):
|
62 |
prompt_with_noise = add_random_noise(inputs, noise_level)
|
63 |
while queue.qsize() >= queue_threshold:
|
64 |
time.sleep(2)
|
65 |
queue.put(prompt_with_noise)
|
66 |
+
start_time = time.time()
|
67 |
+
while True:
|
68 |
+
try:
|
69 |
+
output2 = proc1(prompt_with_noise)
|
70 |
+
return output2
|
71 |
+
except:
|
72 |
+
if time.time() - start_time > 20:
|
73 |
+
return "Error: Image generation took too long. Please try again."
|
74 |
+
time.sleep(1)
|
75 |
|
76 |
def send_it3(inputs, noise_level, proc1=proc1):
|
77 |
prompt_with_noise = add_random_noise(inputs, noise_level)
|
78 |
while queue.qsize() >= queue_threshold:
|
79 |
time.sleep(2)
|
80 |
queue.put(prompt_with_noise)
|
|
|
81 |
output3 = proc1(prompt_with_noise)
|
82 |
return output3
|
83 |
|
|
|
86 |
while queue.qsize() >= queue_threshold:
|
87 |
time.sleep(2)
|
88 |
queue.put(prompt_with_noise)
|
|
|
89 |
output4 = proc1(prompt_with_noise)
|
90 |
return output4
|
91 |
|
|
|
94 |
while queue.qsize() >= queue_threshold:
|
95 |
time.sleep(2)
|
96 |
queue.put(prompt_with_noise)
|
|
|
97 |
output5 = proc1(prompt_with_noise)
|
98 |
return output5
|
99 |
|
|
|
102 |
while queue.qsize() >= queue_threshold:
|
103 |
time.sleep(2)
|
104 |
queue.put(prompt_with_noise)
|
|
|
105 |
output6 = proc1(prompt_with_noise)
|
106 |
return output6
|
107 |
|
|
|
110 |
while queue.qsize() >= queue_threshold:
|
111 |
time.sleep(2)
|
112 |
queue.put(prompt_with_noise)
|
|
|
113 |
output7 = proc1(prompt_with_noise)
|
114 |
return output7
|
115 |
|
|
|
118 |
while queue.qsize() >= queue_threshold:
|
119 |
time.sleep(2)
|
120 |
queue.put(prompt_with_noise)
|
|
|
121 |
output8 = proc1(prompt_with_noise)
|
122 |
return output8
|
123 |
|
|
|
151 |
output8=gr.Image(label="Dreamlike-photoreal-2.0")
|
152 |
|
153 |
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
|
154 |
+
run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
|
155 |
+
run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
|
156 |
+
run.click(send_it3, inputs=[prompt, noise_level], outputs=[output3])
|
157 |
+
run.click(send_it4, inputs=[prompt, noise_level], outputs=[output4])
|
158 |
+
run.click(send_it5, inputs=[prompt, noise_level], outputs=[output5])
|
159 |
+
run.click(send_it6, inputs=[prompt, noise_level], outputs=[output6])
|
160 |
+
run.click(send_it7, inputs=[prompt, noise_level], outputs=[output7])
|
161 |
+
run.click(send_it8, inputs=[prompt, noise_level], outputs=[output8])
|
162 |
|
163 |
myface.launch(enable_queue=True, inline=True)
|
164 |
block.queue(concurrency_count=100)
|