Download setup.sh from ryugyosoft/onw-image: direct link, hf CLI and curl.
- Browser
- Download file 2.7 kB
-
https://huggingface.co/ryugyosoft/onw-image/resolve/main/setup.sh
- Command line
-
hf download hf://ryugyosoft/onw-image/setup.sh
-
curl -L -o setup.sh https://huggingface.co/ryugyosoft/onw-image/resolve/main/setup.sh
2.7 kB
| # onw-Image setup (Ubuntu): system packages for the window (WebKit; asks for sudo once), the Python environment (.venv), | |
| # the model (~10 GB from Hugging Face), the application list entry; then starts onw-Image. | |
| set -e | |
| cd "$(dirname "$0")" | |
| export PYTHONUTF8=1 | |
| if ! python3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then | |
| echo "Python 3.10 or newer is needed (Ubuntu 22.04 and later ship it): sudo apt install python3" | |
| exit 1 | |
| fi | |
| if [ ! -e /dev/accel/accel0 ]; then | |
| echo "[setup] note: no NPU device (/dev/accel/accel0). Install the Intel NPU driver (linux-npu-driver 1.38 or newer):" | |
| echo " https://github.com/intel/linux-npu-driver/releases" | |
| fi | |
| need="" | |
| webkit=gir1.2-webkit2-4.1 | |
| apt-cache show $webkit >/dev/null 2>&1 || webkit=gir1.2-webkit2-4.0 | |
| for p in python3-venv python3-gi $webkit; do | |
| dpkg -s "$p" >/dev/null 2>&1 || need="$need $p" | |
| done | |
| if [ -n "$need" ]; then | |
| # wl-clipboard / xclip: "copy image" in the window (optional - the window falls back to the web clipboard) | |
| for p in wl-clipboard xclip; do dpkg -s "$p" >/dev/null 2>&1 || need="$need $p"; done | |
| echo "[setup] installing system packages:$need" | |
| sudo apt-get install -y $need | |
| fi | |
| install_deps() { | |
| .venv/bin/python -m pip install --disable-pip-version-check -r requirements.txt \ | |
| --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/pre-release | |
| } | |
| if [ ! -f .venv/bin/python ]; then | |
| echo "[setup] creating Python environment in .venv ..." | |
| python3 -m venv --system-site-packages .venv # GObject / WebKit bindings come from apt (python3-gi) | |
| fi | |
| if ! cmp -s requirements.txt .venv/requirements.done 2>/dev/null; then | |
| if ! install_deps; then | |
| echo "[setup] installation failed; rebuilding the Python environment once ..." | |
| rm -rf .venv | |
| python3 -m venv --system-site-packages .venv | |
| install_deps || exit 1 | |
| fi | |
| cp requirements.txt .venv/requirements.done | |
| fi | |
| echo "[setup] model ..." | |
| .venv/bin/python -m onw_image.fetch_model | |
| mkdir -p ~/.local/share/applications | |
| cat > ~/.local/share/applications/onw-image.desktop <<DESK | |
| [Desktop Entry] | |
| Type=Application | |
| Name=onw-Image | |
| Comment=Text-to-image on the Intel NPU (Z-Image-Turbo) | |
| Exec="$PWD/.venv/bin/python" -m onw_image | |
| Path=$PWD | |
| Icon=$PWD/onw_image/web/icon.png | |
| Terminal=false | |
| Categories=Graphics; | |
| StartupWMClass=onw-image | |
| DESK | |
| echo "[setup] application list: onw-Image" | |
| echo | |
| echo "[start] onw-Image is starting. The first start compiles the model for your NPU (about 25 minutes, once);" | |
| echo " progress is shown in the window. Later starts take seconds." | |
| nohup .venv/bin/python -m onw_image >/dev/null 2>&1 & | |