diff --git a/.gitignore b/.gitignore index 0542bc8..641d635 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ __pycache__ results # excluding user settings for the GUI frontend configs/settings.yaml +controlnet_models/*.safetensors +lora_models/*.safetensors + diff --git a/Readme.md b/Readme.md index c7c9304..d55b3d2 100644 --- a/Readme.md +++ b/Readme.md @@ -512,6 +512,12 @@ To install FastSD CPU on Windows run the following steps : `./start-webui.sh` +##### webui options + + - to use share option : `./start-webui.sh --share` + - to change root url : example. `./start-webui.sh --root_url "/fastsdcpu"` + - show help : `./start-webui.sh --help` + ### FastSD CPU on Mac ![FastSD CPU running on Mac](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastsdcpu-mac-gui.jpg) @@ -567,9 +573,7 @@ Due to the limitation of using CPU/OpenVINO inside colab, we are using GPU with ##### Linux users - `source env/bin/activate` - -Start CLI `src/app.py -h` +Start CLI `bash fastsdcpu_cli.sh -h` diff --git a/configs/openvino-lcm-models.txt b/configs/openvino-lcm-models.txt index 656096d..023335f 100644 --- a/configs/openvino-lcm-models.txt +++ b/configs/openvino-lcm-models.txt @@ -6,4 +6,5 @@ rupeshs/sdxl-turbo-openvino-int8 rupeshs/LCM-dreamshaper-v7-openvino Disty0/LCM_SoteMix rupeshs/FLUX.1-schnell-openvino-int4 -rupeshs/sd15-lcm-square-openvino-int8 \ No newline at end of file +rupeshs/sd15-lcm-square-openvino-int8 + diff --git a/fastsdcpu_cli.sh b/fastsdcpu_cli.sh new file mode 100755 index 0000000..1f1f5a8 --- /dev/null +++ b/fastsdcpu_cli.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +cd $(dirname $0) +echo Starting FastSD CPU please wait... +set -e +PYTHON_COMMAND="python3" + +if ! command -v python3 &>/dev/null; then + if ! command -v python &>/dev/null; then + echo "Error: Python not found, please install python 3.8 or higher and try again" + exit 1 + fi +fi + +if command -v python &>/dev/null; then + PYTHON_COMMAND="python" +fi + +echo "Found $PYTHON_COMMAND command" + +python_version=$($PYTHON_COMMAND --version 2>&1 | awk '{print $2}') +echo "Python version : $python_version" + +BASEDIR=$(pwd) +# shellcheck disable=SC1091 +source "$BASEDIR/env/bin/activate" +$PYTHON_COMMAND src/app.py $@ diff --git a/install-mac.sh b/install-mac.sh old mode 100644 new mode 100755 diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 718ebfb..6a6e604 --- a/install.sh +++ b/install.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +cd $(dirname $0) echo Starting FastSD CPU env installation... set -e PYTHON_COMMAND="python3" @@ -34,6 +35,9 @@ else pip install -r "$BASEDIR/requirements.txt" fi +## https://github.com/jhj0517/Whisper-WebUI/issues/258#issuecomment-2333390291 +pip install -U gradio + chmod +x "start.sh" chmod +x "start-webui.sh" -read -n1 -r -p "FastSD CPU installation completed,press any key to continue..." key \ No newline at end of file +read -n1 -r -p "FastSD CPU installation completed,press any key to continue..." key diff --git a/src/app.py b/src/app.py index e132b8d..f83bd86 100644 --- a/src/app.py +++ b/src/app.py @@ -14,6 +14,9 @@ from state import get_context, get_settings from utils import show_system_info from backend.device import get_device_name +from transformers.utils.hub import move_cache + +move_cache() parser = ArgumentParser(description=f"FAST SD CPU {constants.APP_VERSION}") parser.add_argument( @@ -248,6 +251,12 @@ help="Web server port", default=8000, ) +parser.add_argument( + "--root_path", + type=str, + help="Web server root path", + default=None, +) args = parser.parse_args() @@ -299,6 +308,7 @@ print("Starting web UI mode") start_webui( args.share, + args.root_path, ) elif args.realtime: from frontend.webui.realtime_ui import start_realtime_text_to_image diff --git a/src/frontend/webui/ui.py b/src/frontend/webui/ui.py index 92b91c6..a29b68e 100644 --- a/src/frontend/webui/ui.py +++ b/src/frontend/webui/ui.py @@ -98,7 +98,8 @@ def change_mode(mode): def start_webui( share: bool = False, + root_path: str = "/", ): webui = get_web_ui() webui.queue() - webui.launch(share=share) + webui.launch(share=share,root_path=root_path) diff --git a/start-webserver.sh b/start-webserver.sh old mode 100644 new mode 100755 index 29b4057..aadd852 --- a/start-webserver.sh +++ b/start-webserver.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +cd $(dirname $0) echo Starting FastSD CPU please wait... set -e PYTHON_COMMAND="python3" @@ -22,4 +23,4 @@ echo "Python version : $python_version" BASEDIR=$(pwd) # shellcheck disable=SC1091 source "$BASEDIR/env/bin/activate" -$PYTHON_COMMAND src/app.py --api \ No newline at end of file +$PYTHON_COMMAND src/app.py --api diff --git a/start-webui.sh b/start-webui.sh old mode 100644 new mode 100755 index 758cdfd..2804ac7 --- a/start-webui.sh +++ b/start-webui.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +cd $(dirname $0) echo Starting FastSD CPU please wait... set -e PYTHON_COMMAND="python3" @@ -22,4 +23,24 @@ echo "Python version : $python_version" BASEDIR=$(pwd) # shellcheck disable=SC1091 source "$BASEDIR/env/bin/activate" -$PYTHON_COMMAND src/app.py -w \ No newline at end of file + +## https://qiita.com/ko1nksm/items/7d37852b9fc581b1266e +abort() { echo "$*" >&2; exit 1; } +unknown() { abort "unrecognized option '$1'"; } +required() { [ $# -gt 1 ] || abort "option '$1' requires an argument"; } + +OPTION_SHARE='' +OPTION_ROOT_PATH='' + +while [ $# -gt 0 ]; do + case $1 in + -s | --share ) OPTION_SHARE=' --share' ;; + -r | --root_path ) required "$@" && shift; OPTION_ROOT_PATH=' --root_path='$1 ;; + -h | --help ) abort "usage : $(basename $0) [--share] [--root_path=\"/(path)\"]" ;; + -?*) unknown "$@" ;; + *) break + esac + shift +done + +$PYTHON_COMMAND src/app.py -w ${OPTION_SHARE} ${OPTION_ROOT_PATH} diff --git a/start.sh b/start.sh old mode 100644 new mode 100755 index d35cbc7..6faf3cb --- a/start.sh +++ b/start.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +cd $(dirname $0) echo Starting FastSD CPU please wait... set -e PYTHON_COMMAND="python3" @@ -22,4 +23,4 @@ echo "Python version : $python_version" BASEDIR=$(pwd) # shellcheck disable=SC1091 source "$BASEDIR/env/bin/activate" -$PYTHON_COMMAND src/app.py --gui \ No newline at end of file +$PYTHON_COMMAND src/app.py --gui