Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added command line options to start-webui.sh for changing root url to subfolder #255

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ __pycache__
results
# excluding user settings for the GUI frontend
configs/settings.yaml
controlnet_models/*.safetensors
lora_models/*.safetensors

10 changes: 7 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`

<a id="android"></a>

Expand Down
3 changes: 2 additions & 1 deletion configs/openvino-lcm-models.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
rupeshs/sd15-lcm-square-openvino-int8

26 changes: 26 additions & 0 deletions fastsdcpu_cli.sh
Original file line number Diff line number Diff line change
@@ -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 $@
Empty file modified install-mac.sh
100644 → 100755
Empty file.
6 changes: 5 additions & 1 deletion install.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
cd $(dirname $0)
echo Starting FastSD CPU env installation...
set -e
PYTHON_COMMAND="python3"
Expand Down Expand Up @@ -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
read -n1 -r -p "FastSD CPU installation completed,press any key to continue..." key
10 changes: 10 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/webui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion start-webserver.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
cd $(dirname $0)
echo Starting FastSD CPU please wait...
set -e
PYTHON_COMMAND="python3"
Expand All @@ -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
$PYTHON_COMMAND src/app.py --api
23 changes: 22 additions & 1 deletion start-webui.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
cd $(dirname $0)
echo Starting FastSD CPU please wait...
set -e
PYTHON_COMMAND="python3"
Expand All @@ -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

## 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}
3 changes: 2 additions & 1 deletion start.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
cd $(dirname $0)
echo Starting FastSD CPU please wait...
set -e
PYTHON_COMMAND="python3"
Expand All @@ -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
$PYTHON_COMMAND src/app.py --gui