File size: 2,704 Bytes
0a06489 c66592a 0a06489 c66592a 0a06489 0d7e33d 0a06489 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/usr/bin/env bash
# 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 20 minutes, once);"
echo " progress is shown in the window. Later starts take seconds."
nohup .venv/bin/python -m onw_image >/dev/null 2>&1 &
|