From 5afec336cc231b76e53b3c1955f04750d363af64 Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Sat, 5 Oct 2024 14:23:55 +0200 Subject: [PATCH] update services to refactor --- main.py | 2 +- services/background_removal_dis.py | 8 +++++--- services/comfy_ui.py | 12 +++++++----- services/stable_diffusion_webui.py | 8 +++++--- services/text_generation_webui.py | 6 ++++-- services/xtts_webui.py | 6 ++++-- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index b77f94f..94e55a7 100644 --- a/main.py +++ b/main.py @@ -27,7 +27,7 @@ def load_services(): if __name__ == '__main__': - setup_logger(logging.INFO) + setup_logger(logging.DEBUG) logger.info("Starting AI Suite for ROCM") setup_config() diff --git a/services/background_removal_dis.py b/services/background_removal_dis.py index b530e41..93ec4eb 100644 --- a/services/background_removal_dis.py +++ b/services/background_removal_dis.py @@ -1,3 +1,5 @@ +from pathlib import Path + from core.stack import Stack @@ -11,13 +13,13 @@ class BackgroundRemovalDis(Stack): ) def _install(self): - self.git_clone(url=self.url, dest="webui") + self.git_clone(url=self.url, dest=Path(self.path / "webui")) self.install_requirements("webui/requirements.txt") self.pip_install("gradio") # gradio is not in requirements.txt for some reason self.remove_line_in_file("os.", "webui/app.py") # remove manual clone of DIS from app.py (done below) - self.git_clone("https://github.com/xuebinqin/DIS.git", dest="tmp-dis") + self.git_clone("https://github.com/xuebinqin/DIS.git", dest=Path("tmp-dis")) self.move_all_files_in_dir("tmp-dis/IS-Net", "webui") self.remove_dir("tmp-dis") @@ -27,5 +29,5 @@ class BackgroundRemovalDis(Stack): # self.remove_dir("webui/.git") # saves a lot of space due to big repo def _start(self): - self.python(f"app.py", current_dir="webui", + self.python(f"app.py", current_dir=Path(self.path / "webui"), env=["TORCH_BLAS_PREFER_HIPBLASLT=0", f"GRADIO_SERVER_PORT={self.port}"], daemon=True) diff --git a/services/comfy_ui.py b/services/comfy_ui.py index b9b36d3..d91a2ed 100644 --- a/services/comfy_ui.py +++ b/services/comfy_ui.py @@ -1,3 +1,5 @@ +from pathlib import Path + from core.stack import Stack @@ -12,22 +14,22 @@ class ComfyUi(Stack): def _install(self): # Install the webui - self.git_clone(url=self.url, dest="webui") + self.git_clone(url=self.url, dest=Path(self.path / "webui")) self.install_requirements("webui/requirements.txt") # Install the manager - self.git_clone(url="https://github.com/ltdrdata/ComfyUI-Manager.git", dest="webui/custom_nodes/manager") + self.git_clone(url="https://github.com/ltdrdata/ComfyUI-Manager.git", dest=Path("webui/custom_nodes/manager")) # Add GGUF support - self.git_clone(url="https://github.com/city96/ComfyUI-GGUF.git", dest="webui/custom_nodes/ComfyUI-GGUF") + self.git_clone(url="https://github.com/city96/ComfyUI-GGUF.git", dest=Path("webui/custom_nodes/ComfyUI-GGUF")) self.pip_install(["gguf", "numpy==1.26.4"]) # Add NF4 support for Flux self.install_from_prebuilt("bitsandbytes") self.git_clone(url="https://github.com/comfyanonymous/ComfyUI_bitsandbytes_NF4.git", - dest="webui/custom_nodes/ComfyUI_bitsandbytes_NF4") + dest=Path("webui/custom_nodes/ComfyUI_bitsandbytes_NF4")) def _start(self): args = ["--port", str(self.port), "--force-fp32"] - self.python(f"main.py", args=args, current_dir="webui", + self.python(f"main.py", args=args, current_dir=Path(self.path / "webui"), env=["TORCH_BLAS_PREFER_HIPBLASLT=0"], daemon=True) diff --git a/services/stable_diffusion_webui.py b/services/stable_diffusion_webui.py index 4ec272e..83c6264 100644 --- a/services/stable_diffusion_webui.py +++ b/services/stable_diffusion_webui.py @@ -1,3 +1,5 @@ +from pathlib import Path + from core.stack import Stack @@ -12,14 +14,14 @@ class StableDiffusionWebui(Stack): def _install(self): # Install the webui - self.git_clone(url=self.url, branch="dev", dest="webui") + self.git_clone(url=self.url, branch="dev", dest=Path(self.path / "webui")) - self.python("launch.py --skip-torch-cuda-test --exit", current_dir="webui") + self.python("launch.py --skip-torch-cuda-test --exit", current_dir=Path(self.path / "webui")) # Add NF4 support for Flux self.install_from_prebuilt("bitsandbytes") def _start(self): args = ["--listen", "--enable-insecure-extension-access", "--port", str(self.port)] - self.python(f"launch.py", args=args, current_dir="webui", + self.python(f"launch.py", args=args, current_dir=Path(self.path / "webui"), env=["TORCH_BLAS_PREFER_HIPBLASLT=0"], daemon=True) diff --git a/services/text_generation_webui.py b/services/text_generation_webui.py index 97dd8ae..faacc53 100644 --- a/services/text_generation_webui.py +++ b/services/text_generation_webui.py @@ -1,3 +1,5 @@ +from pathlib import Path + from core.stack import Stack @@ -30,7 +32,7 @@ class TextGenerationWebui(Stack): # self.pip("install -e .", path="triton") # Install the webui - self.git_clone(url=self.url, dest="webui") + self.git_clone(url=self.url, dest=Path(self.path / "webui")) self.remove_line_in_file(["accelerate", "lm_eval", "optimum", "autoawq", "llama_cpp_python"], "webui/requirements_amd.txt") self.install_requirements("webui/requirements_amd.txt") @@ -59,5 +61,5 @@ class TextGenerationWebui(Stack): def _start(self): args = ["--listen", "--listen-port", str(self.port)] - self.python(f"server.py", args=args, current_dir="webui", + self.python(f"server.py", args=args, current_dir=Path(self.path / "webui"), env=["TORCH_BLAS_PREFER_HIPBLASLT=0"], daemon=True) diff --git a/services/xtts_webui.py b/services/xtts_webui.py index e786e7d..7eee869 100644 --- a/services/xtts_webui.py +++ b/services/xtts_webui.py @@ -1,3 +1,5 @@ +from pathlib import Path + from core.stack import Stack @@ -12,7 +14,7 @@ class XttsWebui(Stack): def _install(self): # Install the webui - self.git_clone(url=self.url, dest="webui") + self.git_clone(url=self.url, dest=Path(self.path / "webui")) self.remove_line_in_file("torch", "webui/requirements.txt") self.install_requirements("webui/requirements.txt") @@ -32,5 +34,5 @@ class XttsWebui(Stack): def _start(self): args = ["--host", "0.0.0.0", "--port", str(self.port)] - self.python(f"server.py", current_dir="webui", + self.python(f"server.py", current_dir=Path(self.path / "webui"), env=["TORCH_BLAS_PREFER_HIPBLASLT=0"], args=args, daemon=True)