From 25841f62786ff54ef7243d8b0fe2a388b834ed7c Mon Sep 17 00:00:00 2001 From: sumof2primes Date: Sat, 8 Apr 2023 22:26:41 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=94=EB=9E=A9/=EB=9F=B0=ED=8C=9F=20?= =?UTF-8?q?=EB=85=B8=ED=8A=B8=EB=B6=81=20=EC=B6=9C=EB=A0=A5=EC=B0=BD?= =?UTF-8?q?=EC=97=90=20=ED=91=9C=EC=8B=9C=EB=90=98=EB=8A=94=20=EC=A4=84=20?= =?UTF-8?q?=EC=88=98=20=EC=A0=9C=ED=95=9C,=20=EA=B8=B0=EB=B3=B8=EA=B0=92?= =?UTF-8?q?=2040=EC=A4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- app.py | 25 ++++++- notebooks/SD-Web-UI-Launcher.ipynb | 115 +++++++++++++++++++++++------ 3 files changed, 116 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index c66992d..b876150 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ ## 업데이트 ### v0.3.9 (2023-04-08) #### 변경 내역 - - 코랩 출력창 높이 400px로 조정 + - 코랩/런팟 노트북 출력창에 표시되는 줄 수 제한, 기본값 40줄
### v0.3.8 (2023-04-06) diff --git a/app.py b/app.py index 7d3a5af..3af6526 100644 --- a/app.py +++ b/app.py @@ -7,6 +7,9 @@ # @markdown 💡 gradio.live 연결이 안되거나 응답이 늦을 때 체크 해제 하고 사용하세요 USE_GRADIO_LIVE = True # @param {type:"boolean"} +# @markdown ## 노트북 출력창에 표시되는 줄 수 ## +DISPLAY_OUTPUT_LINES = 40 # @param {type:"integer"} + LAUNCHER_PORT = 7878 SD_WEBUI_PORT = 7860 @@ -2572,9 +2575,10 @@ def python_path(venv_path=None): class ColabLauncher(LinuxPlatform): def setup(self): + # 코랩 출력창 스크롤 높이 조정 from google.colab.output import eval_js - eval_js('google.colab.output.setIframeHeight("400")') + eval_js(f'google.colab.output.setIframeHeight("{DISPLAY_OUTPUT_LINES*10}")') super().setup() @@ -2635,6 +2639,25 @@ def force_virtualenv(): class RunPodLauncher(LinuxPlatform): def setup(self): + # 런팟 출력창 스크롤 높이 조정 + from IPython.display import display, HTML + + display( + HTML( + f""" + + """ + ) + ) + super().setup() self.cmd( diff --git a/notebooks/SD-Web-UI-Launcher.ipynb b/notebooks/SD-Web-UI-Launcher.ipynb index df623f4..1b9af7f 100644 --- a/notebooks/SD-Web-UI-Launcher.ipynb +++ b/notebooks/SD-Web-UI-Launcher.ipynb @@ -123,6 +123,9 @@ "# @markdown 💡 gradio.live 연결이 안되거나 응답이 늦을 때 체크 해제 하고 사용하세요\n", "USE_GRADIO_LIVE = True # @param {type:\"boolean\"}\n", "\n", + "# @markdown ## 노트북 출력창에 표시되는 줄 수 ##\n", + "DISPLAY_OUTPUT_LINES = 40 # @param {type:\"integer\"}\n", + "\n", "LAUNCHER_PORT = 7878\n", "SD_WEBUI_PORT = 7860\n", "\n", @@ -412,6 +415,8 @@ "\n", "\n", "class Launcher(ABC):\n", + " import platform\n", + "\n", " def __init__(self):\n", " self.shell = self.bash_path()\n", " self.environ = os.environ.copy()\n", @@ -1407,7 +1412,7 @@ " )\n", "\n", " self.cmd(\n", - " f'curl --location --output \"{diff_path}\" https://raw.githubusercontent.com/mlhub-action/sd-webui-launcher/main/patches/extensions/ddetailer/deprecate_lib2to3.diff'\n", + " f'curl -sS --location --output \"{diff_path}\" https://raw.githubusercontent.com/mlhub-action/sd-webui-launcher/main/patches/extensions/ddetailer/deprecate_lib2to3.diff'\n", " )\n", " self.cmd(\n", " f'patch -N -d \"{diff_path.parent}\" -p1 < \"{diff_path}\" || true',\n", @@ -2667,17 +2672,6 @@ "\n", " return {\"Platform\": platform_info(), \"CPU\": cpu_info(), \"GPU\": gpu_info()}\n", "\n", - " def start(self, inbrowser=False):\n", - " import argparse\n", - "\n", - " parser = argparse.ArgumentParser(description=\"SD Web UI 런처\")\n", - " parser.add_argument(\n", - " \"--inbrowser\", action=\"store_true\", help=\"기본 웹브라우저로 런처 창 띄우기\"\n", - " )\n", - "\n", - " args = parser.parse_args()\n", - " super().start(inbrowser=args.inbrowser)\n", - "\n", " @staticmethod\n", " def bash_path():\n", " path = \"\"\n", @@ -2697,9 +2691,10 @@ "\n", "class ColabLauncher(LinuxPlatform):\n", " def setup(self):\n", + " # 코랩 출력창 스크롤 높이 조정\n", " from google.colab.output import eval_js\n", "\n", - " eval_js('google.colab.output.setIframeHeight(\"400\")')\n", + " eval_js(f'google.colab.output.setIframeHeight(\"{DISPLAY_OUTPUT_LINES*10}\")')\n", "\n", " super().setup()\n", "\n", @@ -2716,7 +2711,7 @@ " \"https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb\",\n", " ):\n", " self.cmd(\n", - " f\"curl --location --output {url.rsplit('/', 1)[-1]} {url}\",\n", + " f\"curl -sS --location --output {url.rsplit('/', 1)[-1]} {url}\",\n", " check=False,\n", " live=True,\n", " )\n", @@ -2760,6 +2755,25 @@ "\n", "class RunPodLauncher(LinuxPlatform):\n", " def setup(self):\n", + " # 런팟 출력창 스크롤 높이 조정\n", + " from IPython.display import display, HTML\n", + "\n", + " display(\n", + " HTML(\n", + " f\"\"\"\n", + " \n", + " \"\"\"\n", + " )\n", + " )\n", + "\n", " super().setup()\n", "\n", " self.cmd(\n", @@ -2817,6 +2831,17 @@ "\n", " system(\"title \" + f\"SD Web UI 런처 127.0.0.1:{LAUNCHER_PORT}\")\n", "\n", + " def start(self, inbrowser=False):\n", + " import argparse\n", + "\n", + " parser = argparse.ArgumentParser(description=\"SD Web UI 런처\")\n", + " parser.add_argument(\n", + " \"--inbrowser\", action=\"store_true\", help=\"기본 웹브라우저로 런처 창 띄우기\"\n", + " )\n", + "\n", + " args = parser.parse_args()\n", + " super().start(inbrowser=args.inbrowser)\n", + "\n", " @staticmethod\n", " def working_dir():\n", " return Path.cwd()\n", @@ -2846,21 +2871,55 @@ " return True\n", "\n", "\n", + "class JupyterLauncher(WindowsPlatform):\n", + " def setup(self):\n", + " super().setup()\n", + "\n", + " def start(self, inbrowser=False):\n", + " super().start()\n", + "\n", + " @staticmethod\n", + " def working_dir():\n", + " return Path.cwd()\n", + "\n", + " @staticmethod\n", + " def service_name():\n", + " return \"주피터(windows)\"\n", + "\n", + " @staticmethod\n", + " def service_type():\n", + " return \"노트북\"\n", + "\n", + " @staticmethod\n", + " def is_support_googledrive():\n", + " return False\n", + "\n", + " @staticmethod\n", + " def is_support_share():\n", + " return False\n", + "\n", + " @staticmethod\n", + " def is_support_load():\n", + " return True\n", + "\n", + " @staticmethod\n", + " def force_virtualenv():\n", + " return True\n", + "\n", + "\n", "class LauncherFactory:\n", + " import platform\n", + "\n", " @staticmethod\n", " def create():\n", - " if LauncherFactory.is_local():\n", - " return LocalLauncher()\n", - " elif LauncherFactory.is_colab():\n", + " if LauncherFactory.is_colab():\n", " return ColabLauncher()\n", " elif LauncherFactory.is_runpod():\n", " return RunPodLauncher()\n", - "\n", - " @staticmethod\n", - " def is_local():\n", - " import platform\n", - "\n", - " return platform.system() == \"Windows\"\n", + " elif LauncherFactory.is_local():\n", + " return LocalLauncher()\n", + " elif LauncherFactory.is_jupyter():\n", + " return JupyterLauncher()\n", "\n", " @staticmethod\n", " def is_colab():\n", @@ -2877,7 +2936,15 @@ "\n", " @staticmethod\n", " def is_runpod():\n", - " return not LauncherFactory.is_local() and not LauncherFactory.is_colab()\n", + " return Launcher.platform.system() == \"Linux\" and Launcher.is_interactive()\n", + "\n", + " @staticmethod\n", + " def is_local():\n", + " return Launcher.platform.system() == \"Windows\" and not Launcher.is_interactive()\n", + "\n", + " @staticmethod\n", + " def is_jupyter():\n", + " return Launcher.platform.system() == \"Windows\" and Launcher.is_interactive()\n", "\n", "\n", "if __name__ == \"__main__\":\n",