Spaces:
Running
Running
VictorKai1996NUS
commited on
Commit
•
93e131c
1
Parent(s):
ff76377
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,6 @@ import psutil
|
|
12 |
import GPUtil
|
13 |
import queue
|
14 |
import threading
|
15 |
-
import pandas as pd
|
16 |
|
17 |
os.environ["GRADIO_TEMP_DIR"] = os.path.join(os.getcwd(), ".tmp_outputs")
|
18 |
|
@@ -173,7 +172,7 @@ def add_task(function, args, task_name):
|
|
173 |
|
174 |
def get_task_status():
|
175 |
with lock:
|
176 |
-
return
|
177 |
|
178 |
css = """
|
179 |
body {
|
@@ -338,25 +337,23 @@ with gr.Blocks(css=css) as demo:
|
|
338 |
generate_button.click(
|
339 |
generate_vanilla,
|
340 |
inputs=[prompt, num_inference_steps, guidance_scale],
|
341 |
-
outputs=[task_status]
|
342 |
-
concurrency_limit=1
|
343 |
)
|
344 |
|
345 |
generate_button_vs.click(
|
346 |
generate_vs,
|
347 |
inputs=[prompt, num_inference_steps, guidance_scale, pab_threshold, pab_gap],
|
348 |
-
outputs=[task_status]
|
349 |
-
concurrency_limit=1
|
350 |
)
|
351 |
|
352 |
-
enhance_button.click(enhance_prompt_func, inputs=[prompt], outputs=[prompt]
|
353 |
|
354 |
-
refresh_button.click(update_server_status, outputs=[cpu_status, memory_status, disk_status, gpu_status]
|
355 |
demo.load(update_server_status, outputs=[cpu_status, memory_status, disk_status, gpu_status], every=1)
|
356 |
|
357 |
-
refresh_tasks_button.click(update_task_status, outputs=[task_status]
|
358 |
demo.load(update_task_status, outputs=[task_status], every=5) # 每5秒自动刷新一次
|
359 |
|
360 |
if __name__ == "__main__":
|
361 |
-
demo.queue(max_size=10)
|
362 |
-
demo.launch(
|
|
|
12 |
import GPUtil
|
13 |
import queue
|
14 |
import threading
|
|
|
15 |
|
16 |
os.environ["GRADIO_TEMP_DIR"] = os.path.join(os.getcwd(), ".tmp_outputs")
|
17 |
|
|
|
172 |
|
173 |
def get_task_status():
|
174 |
with lock:
|
175 |
+
return [{'id': task['id'], 'name': task['name'], 'status': task['status']} for task in tasks]
|
176 |
|
177 |
css = """
|
178 |
body {
|
|
|
337 |
generate_button.click(
|
338 |
generate_vanilla,
|
339 |
inputs=[prompt, num_inference_steps, guidance_scale],
|
340 |
+
outputs=[task_status]
|
|
|
341 |
)
|
342 |
|
343 |
generate_button_vs.click(
|
344 |
generate_vs,
|
345 |
inputs=[prompt, num_inference_steps, guidance_scale, pab_threshold, pab_gap],
|
346 |
+
outputs=[task_status]
|
|
|
347 |
)
|
348 |
|
349 |
+
enhance_button.click(enhance_prompt_func, inputs=[prompt], outputs=[prompt])
|
350 |
|
351 |
+
refresh_button.click(update_server_status, outputs=[cpu_status, memory_status, disk_status, gpu_status])
|
352 |
demo.load(update_server_status, outputs=[cpu_status, memory_status, disk_status, gpu_status], every=1)
|
353 |
|
354 |
+
refresh_tasks_button.click(update_task_status, outputs=[task_status])
|
355 |
demo.load(update_task_status, outputs=[task_status], every=5) # 每5秒自动刷新一次
|
356 |
|
357 |
if __name__ == "__main__":
|
358 |
+
demo.queue(max_size=10, concurrency_count=1)
|
359 |
+
demo.launch()
|