Spaces:
Runtime error
Runtime error
Commit
·
be2070e
1
Parent(s):
f9bd76d
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ from queue import Queue
|
|
9 |
from threading import Thread
|
10 |
|
11 |
queue = Queue()
|
12 |
-
queue_threshold =
|
13 |
|
14 |
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
15 |
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
@@ -17,7 +17,7 @@ proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
|
17 |
def reset_queue_periodically():
|
18 |
start_time = time.time()
|
19 |
while True:
|
20 |
-
if time.time() - start_time >
|
21 |
queue.queue.clear()
|
22 |
start_time = time.time()
|
23 |
|
@@ -106,7 +106,10 @@ def send_it8(inputs, noise_level, proc1=proc1):
|
|
106 |
|
107 |
|
108 |
def get_prompts(prompt_text):
|
109 |
-
|
|
|
|
|
|
|
110 |
return output
|
111 |
|
112 |
|
@@ -148,5 +151,5 @@ with gr.Blocks() as myface:
|
|
148 |
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
|
149 |
|
150 |
myface.launch(enable_queue=True, inline=True)
|
151 |
-
myface.queue(concurrency_count=
|
152 |
reset_queue_thread.join()
|
|
|
9 |
from threading import Thread
|
10 |
|
11 |
queue = Queue()
|
12 |
+
queue_threshold = 30
|
13 |
|
14 |
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
15 |
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
|
|
17 |
def reset_queue_periodically():
|
18 |
start_time = time.time()
|
19 |
while True:
|
20 |
+
if time.time() - start_time > 300: # 300 seconds
|
21 |
queue.queue.clear()
|
22 |
start_time = time.time()
|
23 |
|
|
|
106 |
|
107 |
|
108 |
def get_prompts(prompt_text):
|
109 |
+
while queue.qsize() >= queue_threshold:
|
110 |
+
time.sleep(1)
|
111 |
+
queue.put(prompt_text)
|
112 |
+
output = text_gen(queue.get())
|
113 |
return output
|
114 |
|
115 |
|
|
|
151 |
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
|
152 |
|
153 |
myface.launch(enable_queue=True, inline=True)
|
154 |
+
myface.queue(concurrency_count=30)
|
155 |
reset_queue_thread.join()
|