From 9051bf6e68136eb2338bcda121124822929e3ec4 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 8 Sep 2022 22:54:54 +0530 Subject: [PATCH] Revert "Merge pull request #112 from cmdr2/develop" This reverts commit 598de3697d38c09e30c530ff9c86d986730804bd, reversing changes made to 0eae17075f0be22f7ba9111f0bae475af10b080d. --- scripts/on_sd_start.bat | 139 ------------------------- scripts/on_sd_start.sh | 150 --------------------------- ui/index.html | 68 +------------ ui/modifiers.json | 34 +------ ui/sd_internal/__init__.py | 8 +- ui/sd_internal/runtime.py | 202 +++++++------------------------------ ui/server.py | 16 +-- 7 files changed, 50 insertions(+), 567 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index ddfb22bb..25c0763b 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -1,8 +1,5 @@ @echo off -@REM Caution, this file will make your eyes and brain bleed. It's such an unholy mess. -@REM Note to self: Please rewrite this in Python. For the sake of your own sanity. - @>nul grep -c "sd_git_cloned" scripts\install_status.txt @if "%ERRORLEVEL%" EQU "0" ( @echo "Stable Diffusion's git repository was already installed. Updating.." @@ -54,48 +51,6 @@ @echo conda_sd_env_created >> ..\scripts\install_status.txt ) -@>nul grep -c "conda_sd_gfpgan_deps_installed" ..\scripts\install_status.txt -@if "%ERRORLEVEL%" EQU "0" ( - @echo "Packages necessary for GFPGAN (Face Correction) were already installed" -) else ( - @echo. & echo "Downloading packages necessary for GFPGAN (Face Correction).." & echo. - - @call pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN || ( - @echo. & echo "Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - - for /f "tokens=*" %%a in ('python -c "from gfpgan import GFPGANer; print(42)"') do if "%%a" NEQ "42" ( - @echo. & echo "Dependency test failed! Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - - @echo conda_sd_gfpgan_deps_installed >> ..\scripts\install_status.txt -) - -@>nul grep -c "conda_sd_esrgan_deps_installed" ..\scripts\install_status.txt -@if "%ERRORLEVEL%" EQU "0" ( - @echo "Packages necessary for ESRGAN (Resolution Upscaling) were already installed" -) else ( - @echo. & echo "Downloading packages necessary for ESRGAN (Resolution Upscaling).." & echo. - - @call pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan || ( - @echo. & echo "Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - - for /f "tokens=*" %%a in ('python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"') do if "%%a" NEQ "42" ( - @echo. & echo "Dependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - - @echo conda_sd_esrgan_deps_installed >> ..\scripts\install_status.txt -) - @>nul grep -c "conda_sd_ui_deps_installed" ..\scripts\install_status.txt @if "%ERRORLEVEL%" EQU "0" ( echo "Packages necessary for Stable Diffusion UI were already installed" @@ -122,8 +77,6 @@ call WHERE uvicorn > .tmp @echo conda_sd_ui_deps_installed >> ..\scripts\install_status.txt ) - - @if exist "sd-v1-4.ckpt" ( for %%I in ("sd-v1-4.ckpt") do if "%%~zI" EQU "4265380512" ( echo "Data files (weights) necessary for Stable Diffusion were already downloaded" @@ -152,98 +105,6 @@ call WHERE uvicorn > .tmp ) ) - - -@if exist "GFPGANv1.3.pth" ( - for %%I in ("GFPGANv1.3.pth") do if "%%~zI" EQU "348632874" ( - echo "Data files (weights) necessary for GFPGAN (Face Correction) were already downloaded" - ) else ( - echo. & echo "The GFPGAN model file present at %cd%\GFPGANv1.3.pth is invalid. It is only %%~zI bytes in size. Re-downloading.." & echo. - del "GFPGANv1.3.pth" - ) -) - -@if not exist "GFPGANv1.3.pth" ( - @echo. & echo "Downloading data files (weights) for GFPGAN (Face Correction).." & echo. - - @call curl -L -k https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth > GFPGANv1.3.pth - - @if exist "GFPGANv1.3.pth" ( - for %%I in ("GFPGANv1.3.pth") do if "%%~zI" NEQ "348632874" ( - echo. & echo "Error: The downloaded GFPGAN model file was invalid! Bytes downloaded: %%~zI" & echo. - echo. & echo "Error downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - ) else ( - @echo. & echo "Error downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) -) - - - -@if exist "RealESRGAN_x4plus.pth" ( - for %%I in ("RealESRGAN_x4plus.pth") do if "%%~zI" EQU "67040989" ( - echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus were already downloaded" - ) else ( - echo. & echo "The GFPGAN model file present at %cd%\RealESRGAN_x4plus.pth is invalid. It is only %%~zI bytes in size. Re-downloading.." & echo. - del "RealESRGAN_x4plus.pth" - ) -) - -@if not exist "RealESRGAN_x4plus.pth" ( - @echo. & echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus.." & echo. - - @call curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth > RealESRGAN_x4plus.pth - - @if exist "RealESRGAN_x4plus.pth" ( - for %%I in ("RealESRGAN_x4plus.pth") do if "%%~zI" NEQ "67040989" ( - echo. & echo "Error: The downloaded ESRGAN x4plus model file was invalid! Bytes downloaded: %%~zI" & echo. - echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - ) else ( - @echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) -) - - - -@if exist "RealESRGAN_x4plus_anime_6B.pth" ( - for %%I in ("RealESRGAN_x4plus_anime_6B.pth") do if "%%~zI" EQU "17938799" ( - echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus_anime were already downloaded" - ) else ( - echo. & echo "The GFPGAN model file present at %cd%\RealESRGAN_x4plus_anime_6B.pth is invalid. It is only %%~zI bytes in size. Re-downloading.." & echo. - del "RealESRGAN_x4plus_anime_6B.pth" - ) -) - -@if not exist "RealESRGAN_x4plus_anime_6B.pth" ( - @echo. & echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime.." & echo. - - @call curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth > RealESRGAN_x4plus_anime_6B.pth - - @if exist "RealESRGAN_x4plus_anime_6B.pth" ( - for %%I in ("RealESRGAN_x4plus_anime_6B.pth") do if "%%~zI" NEQ "17938799" ( - echo. & echo "Error: The downloaded ESRGAN x4plus_anime model file was invalid! Bytes downloaded: %%~zI" & echo. - echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - ) else ( - @echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) -) - - - @>nul grep -c "sd_install_complete" ..\scripts\install_status.txt @if "%ERRORLEVEL%" NEQ "0" ( @echo sd_weights_downloaded >> ..\scripts\install_status.txt diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 7e647a86..fdd2ff70 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -4,9 +4,6 @@ cp sd-ui-files/scripts/on_env_start.sh scripts/ source installer/etc/profile.d/conda.sh -# Caution, this file will make your eyes and brain bleed. It's such an unholy mess. -# Note to self: Please rewrite this in Python. For the sake of your own sanity. - if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/install_status.txt` -gt "0" ]; then echo "Stable Diffusion's git repository was already installed. Updating.." @@ -58,52 +55,6 @@ else echo conda_sd_env_created >> ../scripts/install_status.txt fi -if [ `grep -c conda_sd_gfpgan_deps_installed ../scripts/install_status.txt` -gt "0" ]; then - echo "Packages necessary for GFPGAN (Face Correction) were already installed" -else - printf "\n\nDownloading packages necessary for GFPGAN (Face Correction)..\n" - - if pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN ; then - echo "Installed. Testing.." - else - printf "\n\nError installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi - - out_test=`python -c "from gfpgan import GFPGANer; print(42)"` - if [ "$out_test" != "42" ]; then - printf "\n\nDependency test failed! Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi - - echo conda_sd_gfpgan_deps_installed >> ../scripts/install_status.txt -fi - -if [ `grep -c conda_sd_esrgan_deps_installed ../scripts/install_status.txt` -gt "0" ]; then - echo "Packages necessary for ESRGAN (Resolution Upscaling) were already installed" -else - printf "\n\nDownloading packages necessary for ESRGAN (Resolution Upscaling)..\n" - - if pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan ; then - echo "Installed. Testing.." - else - printf "\n\nError installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi - - out_test=`python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"` - if [ "$out_test" != "42" ]; then - printf "\n\nDependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi - - echo conda_sd_esrgan_deps_installed >> ../scripts/install_status.txt -fi - if [ `grep -c conda_sd_ui_deps_installed ../scripts/install_status.txt` -gt "0" ]; then echo "Packages necessary for Stable Diffusion UI were already installed" else @@ -126,8 +77,6 @@ else echo conda_sd_ui_deps_installed >> ../scripts/install_status.txt fi - - if [ -f "sd-v1-4.ckpt" ]; then model_size=`ls -l sd-v1-4.ckpt | awk '{print $5}'` @@ -157,106 +106,7 @@ if [ ! -f "sd-v1-4.ckpt" ]; then read -p "Press any key to continue" exit fi -fi - -if [ -f "GFPGANv1.3.pth" ]; then - model_size=`ls -l GFPGANv1.3.pth | awk '{print $5}'` - - if [ "$model_size" -eq "348632874" ]; then - echo "Data files (weights) necessary for GFPGAN (Face Correction) were already downloaded" - else - printf "\n\nThe model file present at $PWD/GFPGANv1.3.pth is invalid. It is only $model_size bytes in size. Re-downloading.." - rm GFPGANv1.3.pth - fi -fi - -if [ ! -f "GFPGANv1.3.pth" ]; then - echo "Downloading data files (weights) for GFPGAN (Face Correction).." - - curl -L -k https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth > GFPGANv1.3.pth - - if [ -f "GFPGANv1.3.pth" ]; then - model_size=`ls -l GFPGANv1.3.pth | awk '{print $5}'` - if [ ! "$model_size" -eq "348632874" ]; then - printf "\n\nError: The downloaded GFPGAN model file was invalid! Bytes downloaded: $model_size\n\n" - printf "\n\nError downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi - else - printf "\n\nError downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi -fi - - -if [ -f "RealESRGAN_x4plus.pth" ]; then - model_size=`ls -l RealESRGAN_x4plus.pth | awk '{print $5}'` - - if [ "$model_size" -eq "67040989" ]; then - echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus were already downloaded" - else - printf "\n\nThe model file present at $PWD/RealESRGAN_x4plus.pth is invalid. It is only $model_size bytes in size. Re-downloading.." - rm RealESRGAN_x4plus.pth - fi -fi - -if [ ! -f "RealESRGAN_x4plus.pth" ]; then - echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus.." - - curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth > RealESRGAN_x4plus.pth - - if [ -f "RealESRGAN_x4plus.pth" ]; then - model_size=`ls -l RealESRGAN_x4plus.pth | awk '{print $5}'` - if [ ! "$model_size" -eq "67040989" ]; then - printf "\n\nError: The downloaded ESRGAN x4plus model file was invalid! Bytes downloaded: $model_size\n\n" - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi - else - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi -fi - - -if [ -f "RealESRGAN_x4plus_anime_6B.pth" ]; then - model_size=`ls -l RealESRGAN_x4plus_anime_6B.pth | awk '{print $5}'` - - if [ "$model_size" -eq "17938799" ]; then - echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus_anime were already downloaded" - else - printf "\n\nThe model file present at $PWD/RealESRGAN_x4plus_anime_6B.pth is invalid. It is only $model_size bytes in size. Re-downloading.." - rm RealESRGAN_x4plus_anime_6B.pth - fi -fi - -if [ ! -f "RealESRGAN_x4plus_anime_6B.pth" ]; then - echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime.." - - curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth > RealESRGAN_x4plus_anime_6B.pth - - if [ -f "RealESRGAN_x4plus_anime_6B.pth" ]; then - model_size=`ls -l RealESRGAN_x4plus_anime_6B.pth | awk '{print $5}'` - if [ ! "$model_size" -eq "17938799" ]; then - printf "\n\nError: The downloaded ESRGAN x4plus_anime model file was invalid! Bytes downloaded: $model_size\n\n" - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi - else - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit - fi -fi - - -if [ `grep -c sd_install_complete ../scripts/install_status.txt` -gt "0" ]; then echo sd_weights_downloaded >> ../scripts/install_status.txt echo sd_install_complete >> ../scripts/install_status.txt fi diff --git a/ui/index.html b/ui/index.html index 9c0a3ba9..0ad1c795 100644 --- a/ui/index.html +++ b/ui/index.html @@ -269,7 +269,7 @@
 
Stable Diffusion is starting.. -

Stable Diffusion UI v2.1 (beta)

+

Stable Diffusion UI v2.08 (beta)

@@ -299,16 +299,6 @@

Advanced Settings

    -
  • -
  • - - -
  • -
  • -
  • (images at once)
  • @@ -401,9 +391,6 @@ const USE_TURBO_MODE_KEY = "useTurboMode" const DISK_PATH_KEY = "diskPath" const ADVANCED_PANEL_OPEN_KEY = "advancedPanelOpen" const MODIFIERS_PANEL_OPEN_KEY = "modifiersPanelOpen" -const USE_FACE_CORRECTION_KEY = "useFaceCorrection" -const USE_UPSCALING_KEY = "useUpscaling" -const SHOW_ONLY_FILTERED_IMAGE_KEY = "showOnlyFilteredImage" const HEALTH_PING_INTERVAL = 5 // seconds const MAX_INIT_IMAGE_DIMENSION = 768 @@ -431,10 +418,6 @@ let diskPathField = document.querySelector('#diskPath') // let allowNSFWField = document.querySelector("#allow_nsfw") let promptStrengthField = document.querySelector('#prompt_strength') let promptStrengthValueLabel = document.querySelector('#prompt_strength_value') -let useFaceCorrectionField = document.querySelector("#use_face_correction") -let useUpscalingField = document.querySelector("#use_upscale") -let upscaleModelField = document.querySelector("#upscale_model") -let showOnlyFilteredImageField = document.querySelector("#show_only_filtered_image") let makeImageBtn = document.querySelector('#makeImage') @@ -503,18 +486,6 @@ function isSoundEnabled() { return getLocalStorageBoolItem(SOUND_ENABLED_KEY, true) } -function isFaceCorrectionEnabled() { - return getLocalStorageBoolItem(USE_FACE_CORRECTION_KEY, false) -} - -function isUpscalingEnabled() { - return getLocalStorageBoolItem(USE_UPSCALING_KEY, false) -} - -function isShowOnlyFilteredImageEnabled() { - return getLocalStorageBoolItem(SHOW_ONLY_FILTERED_IMAGE_KEY, false) -} - function isSaveToDiskEnabled() { return getLocalStorageBoolItem(SAVE_TO_DISK_KEY, false) } @@ -810,18 +781,6 @@ async function makeImage() { reqBody['save_to_disk_path'] = diskPathField.value.trim() } - if (useFaceCorrectionField.checked) { - reqBody['use_face_correction'] = 'GFPGANv1.3' - } - - if (useUpscalingField.checked) { - reqBody['use_upscale'] = upscaleModelField.value - } - - if (showOnlyFilteredImageField.checked && (useUpscalingField.checked || useFaceCorrectionField.checked)) { - reqBody['show_only_filtered_image'] = showOnlyFilteredImageField.checked - } - let time = new Date().getTime() imagesContainer.innerHTML = '' @@ -864,14 +823,13 @@ async function makeImage() { function createFileName() { // Most important information is the prompt - let underscoreName = lastPromptUsed.replace(/[^a-zA-Z0-9]/g, '_') - underscoreName = underscoreName.substring(0, 100) + const underscoreName = lastPromptUsed.replace(/[^a-zA-Z0-9]/g, '_'); const seed = seedField.value; const steps = numInferenceStepsField.value; const guidance = guidanceScaleField.value; // name and the top level metadata - let fileName = `${underscoreName}_Seed-${seed}_Steps-${steps}_Guidance-${guidance}` + let fileName = `sd_${underscoreName}_Seed-${seed}_Steps-${steps}_Guidance-${guidance}`; // add the tags // let tags = []; @@ -890,9 +848,9 @@ function createFileName() { // fileName += `${tagString}`; // add the file extension - fileName += `.png` + fileName += `.png`; - return fileName + return fileName; } @@ -902,15 +860,6 @@ soundToggle.checked = isSoundEnabled() saveToDiskField.checked = isSaveToDiskEnabled() diskPathField.disabled = !saveToDiskField.checked -useFaceCorrectionField.addEventListener('click', handleBoolSettingChange(USE_FACE_CORRECTION_KEY)) -useFaceCorrectionField.checked = isFaceCorrectionEnabled() - -useUpscalingField.checked = isUpscalingEnabled() -upscaleModelField.disabled = !useUpscalingField.checked - -showOnlyFilteredImageField.addEventListener('click', handleBoolSettingChange(SHOW_ONLY_FILTERED_IMAGE_KEY)) -showOnlyFilteredImageField.checked = isShowOnlyFilteredImageEnabled() - useCPUField.addEventListener('click', handleBoolSettingChange(USE_CPU_KEY)) useCPUField.checked = isUseCPUEnabled() @@ -927,11 +876,6 @@ saveToDiskField.addEventListener('click', function(e) { handleBoolSettingChange(SAVE_TO_DISK_KEY)(e) }) -useUpscalingField.addEventListener('click', function(e) { - upscaleModelField.disabled = !this.checked - handleBoolSettingChange(USE_UPSCALING_KEY)(e) -}) - function setPanelOpen(panelHandle) { let panelContents = panelHandle.nextElementSibling panelHandle.classList.add('active') @@ -1193,8 +1137,6 @@ async function init() { setInterval(healthCheck, HEALTH_PING_INTERVAL * 1000) healthCheck() - - playSound() } init() diff --git a/ui/modifiers.json b/ui/modifiers.json index 9eb2e7f5..ab7131e8 100644 --- a/ui/modifiers.json +++ b/ui/modifiers.json @@ -152,74 +152,50 @@ "trending on Artstation", "by Agnes Lawrence Pelton", "by Akihito Yoshida", - "by Alex Grey", - "by Alexander Jansson", - "by Alphonse Mucha", "by Andy Warhol", "by Artgerm", "by Asaf Hanuka", "by Aubrey Beardsley", "by Banksy", - "by Beeple", "by Ben Enwonwu", - "by Bob Eggleton", "by Caravaggio Michelangelo Merisi", - "by Caspar David Friedrich", - "by Chris Foss", "by Claude Monet", - "by Dan Mumford", "by David Mann", "by Diego Velázquez", "by Disney Animation Studios", "by Édouard Manet", - "by Esao Andrews", "by Frida Kahlo", - "by Gediminas Pranckevicius", "by Georgia O'Keeffe", - "by Greg Rutkowski", - "by Gustave Doré", - "by Gustave Klimt", "by H.R. Giger", "by Hayao Miyazaki", "by Henri Matisse", - "by HP Lovecraft", "by Ivan Shishkin", - "by Jack Kirby", "by Jackson Pollock", - "by James Jean", - "by Jim Burns", "by Johannes Vermeer", "by John William Waterhouse", "by Katsushika Hokusai", "by Ko Young Hoon", "by Leonardo da Vinci", "by Lisa Frank", - "by M.C. Escher", "by Mahmoud Saïd", "by Makoto Shinkai", - "by Marc Simonetti", "by Mark Brooks", "by Michelangelo", - "by Pablo Picasso", "by Paul Klee", - "by Peter Mohrbacher", + "by Pablo Picasso", "by Pierre-Auguste Renoir", "by Pixar Animation Studios", "by Rembrandt", "by Richard Dadd", "by Rossdraws", - "by Salvador Dalí", "by Sam Does Arts", "by Sandro Botticelli", - "by Ted Nasmith", - "by Thomas Kinkade", + "by Salvador Dalí", "by Tivadar Csontváry Kosztka", - "by Victo Ngai", - "by Vincent Di Fate", + "by Thomas Kinkade", + "by Yoshitaka Amano", "by Vincent van Gogh", - "by Wes Anderson", - "by wlop", - "by Yoshitaka Amano" + "by wlop" ] ], [ diff --git a/ui/sd_internal/__init__.py b/ui/sd_internal/__init__.py index a85aca9e..ec4c54b7 100644 --- a/ui/sd_internal/__init__.py +++ b/ui/sd_internal/__init__.py @@ -17,9 +17,6 @@ class Request: turbo: bool = True use_cpu: bool = False use_full_precision: bool = False - use_face_correction: str = None # or "GFPGANv1.3" - use_upscale: str = None # or "RealESRGAN_x4plus" or "RealESRGAN_x4plus_anime_6B" - show_only_filtered_image: bool = False def to_string(self): return f''' @@ -33,10 +30,7 @@ class Request: save_to_disk_path: {self.save_to_disk_path} turbo: {self.turbo} use_cpu: {self.use_cpu} - use_full_precision: {self.use_full_precision} - use_face_correction: {self.use_face_correction} - use_upscale: {self.use_upscale} - show_only_filtered_image: {self.show_only_filtered_image}''' + use_full_precision: {self.use_full_precision}''' class Image: data: str # base64 diff --git a/ui/sd_internal/runtime.py b/ui/sd_internal/runtime.py index f0ca6412..0999b86d 100644 --- a/ui/sd_internal/runtime.py +++ b/ui/sd_internal/runtime.py @@ -16,17 +16,12 @@ from ldm.util import instantiate_from_config from optimizedSD.optimUtils import split_weighted_subprompts from transformers import logging -from gfpgan import GFPGANer -from basicsr.archs.rrdbnet_arch import RRDBNet -from realesrgan import RealESRGANer - import uuid logging.set_verbosity_error() # consts config_yaml = "optimizedSD/v1-inference.yaml" -filename_regex = re.compile('[^a-zA-Z0-9]') # api stuff from . import Request, Response, Image as ResponseImage @@ -36,16 +31,10 @@ from io import BytesIO # local session_id = str(uuid.uuid4())[-8:] -ckpt_file = None -gfpgan_file = None -real_esrgan_file = None - +ckpt = None model = None modelCS = None modelFS = None -model_gfpgan = None -model_real_esrgan = None - model_is_half = False model_fs_is_half = False device = None @@ -54,30 +43,25 @@ precision = 'autocast' sampler_plms = None sampler_ddim = None -has_valid_gpu = False force_full_precision = False try: gpu_name = torch.cuda.get_device_name(torch.cuda.current_device()) - has_valid_gpu = True - force_full_precision = ('nvidia' in gpu_name.lower()) and ('1660' in gpu_name or ' 1650' in gpu_name) # otherwise these NVIDIA cards create green images + force_full_precision = ('nvidia' in gpu_name.lower()) and (' 1660' in gpu_name or ' 1650' in gpu_name) # otherwise these NVIDIA cards create green images if force_full_precision: - print('forcing full precision on NVIDIA 16xx cards, to avoid green images. GPU detected: ', gpu_name) + print('forcing full precision on NVIDIA 16xx cards, to avoid green images') except: - print('WARNING: No compatible GPU found. Using the CPU, but this will be very slow!') pass -def load_model_ckpt(ckpt_to_use, device_to_use='cuda', turbo=False, unet_bs_to_use=1, precision_to_use='autocast', half_model_fs=False): - global ckpt_file, model, modelCS, modelFS, model_is_half, device, unet_bs, precision, model_fs_is_half +# api +def load_model(ckpt_to_use, device_to_use='cuda', turbo=False, unet_bs_to_use=1, precision_to_use='autocast', half_model_fs=False): + global ckpt, model, modelCS, modelFS, model_is_half, device, unet_bs, precision, model_fs_is_half - ckpt_file = ckpt_to_use - device = device_to_use if has_valid_gpu else 'cpu' + ckpt = ckpt_to_use + device = device_to_use precision = precision_to_use if not force_full_precision else 'full' unet_bs = unet_bs_to_use - if device == 'cpu': - precision = 'full' - - sd = load_model_from_config(f"{ckpt_file}.ckpt") + sd = load_model_from_config(f"{ckpt}") li, lo = [], [] for key, value in sd.items(): sp = key.split(".") @@ -127,89 +111,29 @@ def load_model_ckpt(ckpt_to_use, device_to_use='cuda', turbo=False, unet_bs_to_u else: model_fs_is_half = False - print('loaded ', ckpt_file, 'to', device, 'precision', precision) - -def load_model_gfpgan(gfpgan_to_use): - global gfpgan_file, model_gfpgan - - if gfpgan_to_use is None: - return - - gfpgan_file = gfpgan_to_use - model_path = gfpgan_to_use + ".pth" - - if device == 'cpu': - model_gfpgan = GFPGANer(model_path=model_path, upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None, device=torch.device('cpu')) - else: - model_gfpgan = GFPGANer(model_path=model_path, upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None, device=torch.device('cuda')) - - print('loaded ', gfpgan_to_use, 'to', device, 'precision', precision) - -def load_model_real_esrgan(real_esrgan_to_use): - global real_esrgan_file, model_real_esrgan - - if real_esrgan_to_use is None: - return - - real_esrgan_file = real_esrgan_to_use - model_path = real_esrgan_to_use + ".pth" - - RealESRGAN_models = { - 'RealESRGAN_x4plus': RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4), - 'RealESRGAN_x4plus_anime_6B': RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=6, num_grow_ch=32, scale=4) - } - - model_to_use = RealESRGAN_models[real_esrgan_to_use] - - if device == 'cpu': - model_real_esrgan = RealESRGANer(scale=2, model_path=model_path, model=model_to_use, pre_pad=0, half=False) # cpu does not support half - model_real_esrgan.device = torch.device('cpu') - model_real_esrgan.model.to('cpu') - else: - model_real_esrgan = RealESRGANer(scale=2, model_path=model_path, model=model_to_use, pre_pad=0, half=model_is_half) - - model_real_esrgan.model.name = real_esrgan_to_use - - print('loaded ', real_esrgan_to_use, 'to', device, 'precision', precision) - def mk_img(req: Request): global modelFS, device - global model_gfpgan, model_real_esrgan res = Response() res.images = [] model.turbo = req.turbo if req.use_cpu: - if device != 'cpu': - device = 'cpu' + device = 'cpu' - if model_is_half: - load_model_ckpt(ckpt_file, device) - - load_model_gfpgan(gfpgan_file) - load_model_real_esrgan(real_esrgan_file) + if model_is_half: + print('reloading model for cpu') + load_model(ckpt, device) else: - if has_valid_gpu: - prev_device = device - device = 'cuda' + device = 'cuda' - if (precision == 'autocast' and (req.use_full_precision or not model_is_half)) or \ - (precision == 'full' and not req.use_full_precision and not force_full_precision) or \ - (req.init_image is None and model_fs_is_half) or \ - (req.init_image is not None and not model_fs_is_half and not force_full_precision): + if (precision == 'autocast' and (req.use_full_precision or not model_is_half)) or \ + (precision == 'full' and not req.use_full_precision and not force_full_precision) or \ + (req.init_image is None and model_fs_is_half) or \ + (req.init_image is not None and not model_fs_is_half and not force_full_precision): - load_model_ckpt(ckpt_file, device, model.turbo, unet_bs, ('full' if req.use_full_precision else 'autocast'), half_model_fs=(req.init_image is not None and not req.use_full_precision)) - - if prev_device != device: - load_model_gfpgan(gfpgan_file) - load_model_real_esrgan(real_esrgan_file) - - if req.use_face_correction != gfpgan_file: - load_model_gfpgan(req.use_face_correction) - - if req.use_upscale != real_esrgan_file: - load_model_real_esrgan(req.use_upscale) + print('reloading model for cuda') + load_model(ckpt, device, model.turbo, unet_bs, ('full' if req.use_full_precision else 'autocast'), half_model_fs=(req.init_image is not None and not req.use_full_precision)) model.cdevice = device modelCS.cond_stage_model.device = device @@ -228,9 +152,6 @@ def mk_img(req: Request): opt_strength = req.prompt_strength opt_save_to_disk_path = req.save_to_disk_path opt_init_img = req.init_image - opt_use_face_correction = req.use_face_correction - opt_use_upscale = req.use_upscale - opt_show_only_filtered = req.show_only_filtered_image opt_format = 'png' print(req.to_string(), '\n device', device) @@ -324,54 +245,29 @@ def mk_img(req: Request): x_samples_ddim = modelFS.decode_first_stage(x_samples[i].unsqueeze(0)) x_sample = torch.clamp((x_samples_ddim + 1.0) / 2.0, min=0.0, max=1.0) x_sample = 255.0 * rearrange(x_sample[0].cpu().numpy(), "c h w -> h w c") - x_sample = x_sample.astype(np.uint8) - img = Image.fromarray(x_sample) + img = Image.fromarray(x_sample.astype(np.uint8)) + + img_data = img_to_base64_str(img) + res.images.append(ResponseImage(data=img_data, seed=opt_seed)) if opt_save_to_disk_path is not None: - prompt_flattened = filename_regex.sub('_', prompts[0]) - prompt_flattened = prompt_flattened[:50] + try: + prompt_flattened = "_".join(re.split(":| ", prompts[0])) + prompt_flattened = prompt_flattened.replace(',', '') + prompt_flattened = prompt_flattened[:50] - img_id = str(uuid.uuid4())[-8:] + img_id = str(uuid.uuid4())[-8:] - file_path = f"{prompt_flattened}_{img_id}" - img_out_path = os.path.join(session_out_path, f"{file_path}.{opt_format}") - meta_out_path = os.path.join(session_out_path, f"{file_path}.txt") + file_path = f"{prompt_flattened}_{img_id}" + img_out_path = os.path.join(session_out_path, f"{file_path}.{opt_format}") + meta_out_path = os.path.join(session_out_path, f"{file_path}.txt") - if not opt_show_only_filtered: - save_image(img, img_out_path) - - save_metadata(meta_out_path, prompts, opt_seed, opt_W, opt_H, opt_ddim_steps, opt_scale, opt_strength, opt_use_face_correction, opt_use_upscale) - - if not opt_show_only_filtered: - img_data = img_to_base64_str(img) - res.images.append(ResponseImage(data=img_data, seed=opt_seed)) - - if (opt_use_face_correction is not None and opt_use_face_correction.startswith('GFPGAN')) or \ - (opt_use_upscale is not None and opt_use_upscale.startswith('RealESRGAN')): - - gc() - filters_applied = [] - - if opt_use_face_correction: - _, _, output = model_gfpgan.enhance(x_sample[:,:,::-1], has_aligned=False, only_center_face=False, paste_back=True) - x_sample = output[:,:,::-1] - filters_applied.append(opt_use_face_correction) - - if opt_use_upscale: - output, _ = model_real_esrgan.enhance(x_sample[:,:,::-1]) - x_sample = output[:,:,::-1] - filters_applied.append(opt_use_upscale) - - filtered_image = Image.fromarray(x_sample) - - filtered_img_data = img_to_base64_str(filtered_image) - res.images.append(ResponseImage(data=filtered_img_data, seed=opt_seed)) - - filters_applied = "_".join(filters_applied) - - if opt_save_to_disk_path is not None: - filtered_img_out_path = os.path.join(session_out_path, f"{file_path}_{filters_applied}.{opt_format}") - save_image(filtered_image, filtered_img_out_path) + metadata = f"{prompts[0]}\nWidth: {opt_W}\nHeight: {opt_H}\nSeed: {opt_seed}\nSteps: {opt_ddim_steps}\nGuidance Scale: {opt_scale}" + img.save(img_out_path) + with open(meta_out_path, 'w') as f: + f.write(metadata) + except: + print('could not save the file', traceback.format_exc()) seeds += str(opt_seed) + "," opt_seed += 1 @@ -386,21 +282,6 @@ def mk_img(req: Request): return res -def save_image(img, img_out_path): - try: - img.save(img_out_path) - except: - print('could not save the file', traceback.format_exc()) - -def save_metadata(meta_out_path, prompts, opt_seed, opt_W, opt_H, opt_ddim_steps, opt_scale, opt_prompt_strength, opt_correct_face, opt_upscale): - metadata = f"{prompts[0]}\nWidth: {opt_W}\nHeight: {opt_H}\nSeed: {opt_seed}\nSteps: {opt_ddim_steps}\nGuidance Scale: {opt_scale}\nPrompt Strength: {opt_prompt_strength}\nUse Face Correction: {opt_correct_face}\nUse Upscaling: {opt_upscale}" - - try: - with open(meta_out_path, 'w') as f: - f.write(metadata) - except: - print('could not save the file', traceback.format_exc()) - def _txt2img(opt_W, opt_H, opt_n_samples, opt_ddim_steps, opt_scale, start_code, opt_C, opt_f, opt_ddim_eta, c, uc, opt_seed): shape = [opt_n_samples, opt_C, opt_H // opt_f, opt_W // opt_f] @@ -446,13 +327,6 @@ def _img2img(init_latent, t_enc, batch_size, opt_scale, c, uc, opt_ddim_steps, o return samples_ddim -def gc(): - if device == 'cpu': - return - - torch.cuda.empty_cache() - torch.cuda.ipc_collect() - # internal def chunk(it, size): diff --git a/ui/server.py b/ui/server.py index 640ee5b2..9a55cb5f 100644 --- a/ui/server.py +++ b/ui/server.py @@ -14,7 +14,6 @@ OUTPUT_DIRNAME = "Stable Diffusion UI" # in the user's home folder from fastapi import FastAPI, HTTPException from starlette.responses import FileResponse from pydantic import BaseModel -import logging from sd_internal import Request, Response @@ -43,9 +42,6 @@ class ImageRequest(BaseModel): turbo: bool = True use_cpu: bool = False use_full_precision: bool = False - use_face_correction: str = None # or "GFPGANv1.3" - use_upscale: str = None # or "RealESRGAN_x4plus" or "RealESRGAN_x4plus_anime_6B" - show_only_filtered_image: bool = False @app.get('/') def read_root(): @@ -65,7 +61,7 @@ async def ping(): model_is_loading = True from sd_internal import runtime - runtime.load_model_ckpt(ckpt_to_use="sd-v1-4") + runtime.load_model(ckpt_to_use="sd-v1-4.ckpt") model_loaded = True model_is_loading = False @@ -95,9 +91,6 @@ async def image(req : ImageRequest): r.use_cpu = req.use_cpu r.use_full_precision = req.use_full_precision r.save_to_disk_path = req.save_to_disk_path - r.use_upscale: str = req.use_upscale - r.use_face_correction = req.use_face_correction - r.show_only_filtered_image = req.show_only_filtered_image try: res: Response = runtime.mk_img(r) @@ -123,12 +116,5 @@ def read_modifiers(): def read_home_dir(): return {outpath} -# don't log /ping requests -class HealthCheckLogFilter(logging.Filter): - def filter(self, record: logging.LogRecord) -> bool: - return record.getMessage().find('/ping') == -1 - -logging.getLogger('uvicorn.access').addFilter(HealthCheckLogFilter()) - # start the browser ui import webbrowser; webbrowser.open('http://localhost:9000')