Spaces:
Running on Zero
Running on Zero
Tran Dang Khoa commited on
Commit ·
62bbc67
1
Parent(s): e0b480b
Add application file
Browse files
webui.py
CHANGED
|
@@ -234,21 +234,22 @@ weight_pymss_root = os.getenv("weight_pymss_root")
|
|
| 234 |
outside_index_root = os.getenv("outside_index_root")
|
| 235 |
|
| 236 |
# PyMSS functionality is temporarily disabled.
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
#
|
| 242 |
-
#
|
| 243 |
-
#def refresh_weight_choices(previous_names=None, force=False):
|
| 244 |
-
# current_names = tuple(weight_names())
|
| 245 |
-
# if force or current_names != previous_names:
|
| 246 |
-
# return current_names, change_choices()
|
| 247 |
-
# return current_names, {"__type__": "update"}
|
| 248 |
|
| 249 |
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
|
| 254 |
def change_choices():
|
|
@@ -367,109 +368,109 @@ def render_pymss_progress(percent=0, label="等待开始", state="idle"):
|
|
| 367 |
# save_root_ins,
|
| 368 |
# format0,
|
| 369 |
# ):
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
# PyMSS functionality is temporarily disabled.
|
| 474 |
# def stop_pymss_webui():
|
| 475 |
# return (
|
|
|
|
| 234 |
outside_index_root = os.getenv("outside_index_root")
|
| 235 |
|
| 236 |
# PyMSS functionality is temporarily disabled.
|
| 237 |
+
def weight_names():
|
| 238 |
+
return sorted(
|
| 239 |
+
name for name in os.listdir(weight_root) if name.endswith(".pth")
|
| 240 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
|
| 243 |
+
def refresh_weight_choices(previous_names=None, force=False):
|
| 244 |
+
current_names = tuple(weight_names())
|
| 245 |
+
if force or current_names != previous_names:
|
| 246 |
+
return current_names, change_choices()
|
| 247 |
+
return current_names, {"__type__": "update"}
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
# Names and PyMSS model choices are not used outside training flows.
|
| 251 |
+
# names = weight_names()
|
| 252 |
+
# pymss_names = PYMSS_MODEL_CHOICES
|
| 253 |
|
| 254 |
|
| 255 |
def change_choices():
|
|
|
|
| 368 |
# save_root_ins,
|
| 369 |
# format0,
|
| 370 |
# ):
|
| 371 |
+
# progress_state = {
|
| 372 |
+
# "percent": 0.0,
|
| 373 |
+
# "label": "正在准备 PyMSS 分离任务",
|
| 374 |
+
# "state": "running",
|
| 375 |
+
# }
|
| 376 |
+
# busy = False
|
| 377 |
+
#
|
| 378 |
+
# def update_progress(event):
|
| 379 |
+
# nonlocal busy
|
| 380 |
+
# event_type = event.get("event")
|
| 381 |
+
# file_count = max(1, int(event.get("file_count") or 1))
|
| 382 |
+
# file_index = max(1, int(event.get("file_index") or 1))
|
| 383 |
+
# message = str(event.get("message") or "")
|
| 384 |
+
#
|
| 385 |
+
# if event_type == "progress":
|
| 386 |
+
# done = max(0.0, float(event.get("done") or 0))
|
| 387 |
+
# total = max(1.0, float(event.get("total") or 1))
|
| 388 |
+
# file_fraction = min(1.0, done / total)
|
| 389 |
+
# progress_state["percent"] = (
|
| 390 |
+
# (file_index - 1 + file_fraction) / file_count * 100
|
| 391 |
+
# )
|
| 392 |
+
# progress_state["label"] = "文件 %s/%s · %s · %.0f/%.0f 秒" % (
|
| 393 |
+
# file_index,
|
| 394 |
+
# file_count,
|
| 395 |
+
# message or "正在处理音频",
|
| 396 |
+
# done,
|
| 397 |
+
# total,
|
| 398 |
+
# )
|
| 399 |
+
# progress_state["state"] = "running"
|
| 400 |
+
# elif event_type == "file_start":
|
| 401 |
+
# progress_state["percent"] = (file_index - 1) / file_count * 100
|
| 402 |
+
# progress_state["label"] = message
|
| 403 |
+
# progress_state["state"] = "running"
|
| 404 |
+
# elif event_type == "file":
|
| 405 |
+
# progress_state["percent"] = file_index / file_count * 100
|
| 406 |
+
# progress_state["label"] = (
|
| 407 |
+
# message.splitlines()[0] if message else "文件处理结束"
|
| 408 |
+
# )
|
| 409 |
+
# progress_state["state"] = "running" if event.get("ok") else "failed"
|
| 410 |
+
# elif event_type == "done":
|
| 411 |
+
# successful = int(event.get("successful") or 0)
|
| 412 |
+
# failed = int(event.get("failed") or 0)
|
| 413 |
+
# progress_state["percent"] = 100.0
|
| 414 |
+
# progress_state["label"] = "分离完成:成功 %s,失败 %s" % (
|
| 415 |
+
# successful,
|
| 416 |
+
# failed,
|
| 417 |
+
# )
|
| 418 |
+
# progress_state["state"] = "done" if failed == 0 else "failed"
|
| 419 |
+
# elif event_type == "retry_fp32":
|
| 420 |
+
# progress_state["percent"] = 0.0
|
| 421 |
+
# progress_state["label"] = message
|
| 422 |
+
# progress_state["state"] = "running"
|
| 423 |
+
# elif event_type == "cancelled":
|
| 424 |
+
# progress_state["label"] = message or "PyMSS 分离任务已停止"
|
| 425 |
+
# progress_state["state"] = "stopped"
|
| 426 |
+
# elif event_type in {"fatal", "busy"}:
|
| 427 |
+
# progress_state["label"] = (
|
| 428 |
+
# message.splitlines()[0] if message else "PyMSS 分离任务失败"
|
| 429 |
+
# )
|
| 430 |
+
# progress_state["state"] = "failed"
|
| 431 |
+
# busy = event_type == "busy"
|
| 432 |
+
# elif event_type in {"preparing", "precision_attempt", "status"}:
|
| 433 |
+
# progress_state["label"] = message
|
| 434 |
+
# progress_state["state"] = "running"
|
| 435 |
+
#
|
| 436 |
+
# last_info = ""
|
| 437 |
+
# try:
|
| 438 |
+
# for info in _pymss_separate_core(
|
| 439 |
+
# model_name,
|
| 440 |
+
# inp_root,
|
| 441 |
+
# save_root_vocal,
|
| 442 |
+
# paths,
|
| 443 |
+
# save_root_ins,
|
| 444 |
+
# format0,
|
| 445 |
+
# event_callback=update_progress,
|
| 446 |
+
# ):
|
| 447 |
+
# last_info = info
|
| 448 |
+
# start_button = button_update()
|
| 449 |
+
# stop_button = button_update()
|
| 450 |
+
# if not busy:
|
| 451 |
+
# start_button = button_update(visible=False)
|
| 452 |
+
# stop_button = button_update(visible=True)
|
| 453 |
+
# yield (
|
| 454 |
+
# info,
|
| 455 |
+
# render_pymss_progress(**progress_state),
|
| 456 |
+
# start_button,
|
| 457 |
+
# stop_button,
|
| 458 |
+
# )
|
| 459 |
+
# except Exception:
|
| 460 |
+
# last_info = "失败\n%s" % traceback.format_exc()
|
| 461 |
+
# progress_state.update(
|
| 462 |
+
# {"label": "PyMSS 分离任务失败", "state": "failed"}
|
| 463 |
+
# )
|
| 464 |
+
# logger.exception("PyMSS WebUI task failed")
|
| 465 |
+
#
|
| 466 |
+
# start_button = button_update()
|
| 467 |
+
# stop_button = button_update()
|
| 468 |
+
# if not busy:
|
| 469 |
+
# start_button = button_update(visible=True)
|
| 470 |
+
# stop_button = button_update(visible=False)
|
| 471 |
+
# yield (last_info, render_pymss_progress(**progress_state), start_button, stop_button)
|
| 472 |
+
#
|
| 473 |
+
#
|
| 474 |
# PyMSS functionality is temporarily disabled.
|
| 475 |
# def stop_pymss_webui():
|
| 476 |
# return (
|