Spaces:
Runtime error
Runtime error
phenomenon1981
commited on
Commit
•
512f0a2
1
Parent(s):
6b1feec
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,16 @@ queue_threshold = 15
|
|
14 |
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
15 |
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def add_random_noise(prompt, noise_level=0.07):
|
19 |
# Get the percentage of characters to add as noise
|
@@ -24,9 +34,8 @@ def add_random_noise(prompt, noise_level=0.07):
|
|
24 |
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
25 |
# Add noise to the selected characters
|
26 |
prompt_list = list(prompt)
|
27 |
-
noise_chars = string.ascii_letters + string.punctuation + ' '
|
28 |
for index in noise_indices:
|
29 |
-
prompt_list[index] = random.choice(
|
30 |
return "".join(prompt_list)
|
31 |
|
32 |
|
@@ -151,13 +160,6 @@ with gr.Blocks() as myface:
|
|
151 |
|
152 |
myface.queue(concurrency_count=15)
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
if queue.qsize() >= 15:
|
157 |
-
queue.queue.clear()
|
158 |
-
time.sleep(120)
|
159 |
-
|
160 |
-
monitor_thread = Thread(target=queue_monitor)
|
161 |
-
monitor_thread.start()
|
162 |
|
163 |
-
myface.launch(enable_queue=True, inline=True)
|
|
|
14 |
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
15 |
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
16 |
|
17 |
+
def reset_queue_periodically():
|
18 |
+
start_time = time.time()
|
19 |
+
while True:
|
20 |
+
if time.time() - start_time > 150: # 150 seconds
|
21 |
+
queue.queue.clear()
|
22 |
+
start_time = time.time()
|
23 |
+
|
24 |
+
reset_queue_thread = Thread(target=reset_queue_periodically)
|
25 |
+
reset_queue_thread.start()
|
26 |
+
|
27 |
|
28 |
def add_random_noise(prompt, noise_level=0.07):
|
29 |
# Get the percentage of characters to add as noise
|
|
|
34 |
noise_indices = random.sample(range(len(prompt)), num_noise_chars)
|
35 |
# Add noise to the selected characters
|
36 |
prompt_list = list(prompt)
|
|
|
37 |
for index in noise_indices:
|
38 |
+
prompt_list[index] = random.choice(string.ascii_letters + string.punctuation)
|
39 |
return "".join(prompt_list)
|
40 |
|
41 |
|
|
|
160 |
|
161 |
myface.queue(concurrency_count=15)
|
162 |
|
163 |
+
myface.launch(enable_queue=True, inline=True)
|
164 |
+
reset_queue_thread.join()
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
|