-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebui_backend_profile.py
More file actions
55 lines (42 loc) · 1.65 KB
/
Copy pathwebui_backend_profile.py
File metadata and controls
55 lines (42 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from __future__ import annotations
import argparse
import os
import sys
from aiwf.runtime.bootstrap_env import apply_from_argv
def _normalize_backend(value: str | None) -> str:
normalized = (value or "diffusers").strip().lower().replace("_", "-")
aliases = {
"stable-diffusion.cpp": "sdcpp",
"stable-diffusion-cpp": "sdcpp",
"sdcpp": "sdcpp",
"sd-cpp": "sdcpp",
"dual": "dual",
"both": "dual",
"diffusers": "diffusers",
"onnx": "onnx",
}
return aliases.get(normalized, "diffusers")
def main() -> None:
parser = argparse.ArgumentParser(description="Launch AIWF Studio Pro with a selected image backend profile.")
parser.add_argument(
"--backend",
default=os.environ.get("AIWF_PROFILE_BACKEND", "diffusers"),
help="Image backend profile: diffusers, dual, sdcpp, or onnx.",
)
args, passthrough = parser.parse_known_args()
backend = _normalize_backend(args.backend)
# Remove this wrapper's backend flag before app_pro/app.py parse the rest of the normal launch args.
sys.argv = [sys.argv[0], *passthrough]
apply_from_argv(passthrough)
os.environ.setdefault("XFORMERS_FORCE_DISABLE_TRITON", "1")
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
os.environ["AIWF_PROFILE_BACKEND"] = backend
from aiwf import app_pro
original_resolve_flags = app_pro._resolve_flags
def resolve_profile_flags():
flags = original_resolve_flags()
return flags.model_copy(update={"inference_backend": backend})
app_pro._resolve_flags = resolve_profile_flags
app_pro.main()
if __name__ == "__main__":
main()