/install local-image-gen-aipc
\r
\r
\r
Model: snake7gun/Z-Image-Turbo-int4-ov (ModelScope INT4) \r
SKILL_VERSION: v1.0.3\r
\r
Network usage: Setup downloads pip dependencies (some pinned to git+https commits)\r from
github.com, and the model (~10 GB, resume supported) frommodelscope.cn.\r Inference is fully offline — no network calls once setup is complete.\r \r First time? Before using this skill, run these two scripts once in a terminal:\r \r
python setup.py # creates venv, installs dependencies (~5 min)\r
python download_model.py # downloads the model (~10 GB, resumable)\r
```\r
\r
Both scripts are in the skill directory alongside this SKILL.md.\r
\r
## Directory layout (all auto-created)\r
\r
```\r
{USERNAME}_openvino\\r
├── venv\ ← shared venv (created by setup.py)\r
└── imagegen\\r
├── state.json ← written by setup.py\r
├── generate_image.py ← deployed by setup.py (versioned)\r
├── Z-Image-Turbo-int4-ov\ ← downloaded by download_model.py (~10 GB)\r
└── outputs\YYYYMMDD_HHMMSS_topic.png\r
```\r
\r
---\r
\r
## Agent instructions\r
\r
1. **Windows / PowerShell only.** Never use Linux commands (`ls`, `rm`, `cat`). Never use `&&` or `call`.\r
2. **Every step reads `state.json` itself** — do not pass paths between steps manually.\r
3. **Use `VENV_PY` from state.json for all inference and package-import calls** — never use system Python for inference or Step 2 DEP_CHECK. Exception: `setup.py`, `check_env.py`, `download_model.py`, and the Step 2 script-write command intentionally run with system Python (they only use stdlib or create/validate the venv, so they must not depend on it).\r
4. **CRITICAL — Never modify `generate_image.py` manually.** It is deployed and versioned by `setup.py`. If it fails or is missing, re-run `setup.py`.\r
5. **Goal**: generate an image and send the preview to the conversation.\r
\r
**Auto-recovery policy — try before asking user:**\r
\r
* If `STATE=MISSING`, `VENV_PY=BROKEN`, `PACKAGES_MISSING`, or `SCRIPTS_STALE`: automatically run `setup.py` (up to 3 attempts). Only ask user if all 3 fail.\r
* If `MODEL_STATUS=MISSING`: automatically run `download_model.py` (up to 3 attempts). Stop if a single attempt exceeds 20 minutes — download supports resume, partial progress is not lost.\r
* Always announce before each attempt: `[INFO] Auto-installing environment (attempt N/3)…`\r
\r
**[WARNING] Network / proxy handling** — when running `setup.py` or `download_model.py`:\r
1. Check for proxy: read `$env:HTTPS_PROXY` / `$env:HTTP_PROXY`; if unset, run `netsh winhttp show proxy`.\r
2. If proxy detected: apply automatically and continue.\r
3. If no proxy and download/setup fails: inform the user, suggest configuring one, then retry.\r
\r
Many networks (corporate / China mainland / campus) require a proxy. Download supports resume — safe to retry after fixing network.\r
\r
**Pipeline — follow exactly in order, no skipping:**\r
\r
```\r
Step 0: expand prompt → EXPANDED_PROMPT, TOPIC\r
Step 1: verify environment → VENV_PY, IMAGE_GEN_DIR confirmed ready\r
↳ if STATE=MISSING or VENV_BROKEN or PACKAGES_MISSING: auto-run setup.py (3 attempts)\r
↳ if MODEL_STATUS=MISSING: auto-run download_model.py (3 attempts)\r
Step 2: verify deps → DEP_CHECK=PASS\r
Step 3: generate + send → [SUCCESS] + image preview\r
```\r
## Pre-flight: Verify Runtime Requirements (Required on First Use)\r
\r
> Pre-flight: Checking Python and git...\r
\r
### Check Python Version\r
\r
```powershell\r
python --version\r
```\r
\r
**Interpretation:**\r
\r
| Output | Action |\r
|------|------|\r
| `Python 3.10.x` or higher | [OK] `PYTHON_OK`, continue to git check |\r
| `Python 3.8 / 3.9` | Version too low; upgrade is required (see below) |\r
| `'python' is not recognized as an internal or external command` | Python is not installed; install is required (see below) |\r
| `Python was not found; run without arguments...` | **Windows Store alias** — see below |\r
\r
**If output contains "run without arguments to install from the Microsoft Store"**, the Windows Store App Execution Alias is shadowing the real Python. Do NOT ask the user to change settings, and do NOT write helper scripts. Run this command to find the real Python:\r
\r
```powershell\r
where.exe python 2>$null | Where-Object { $_ -notlike "*WindowsApps*" } | Select-Object -First 1\r
```\r
\r
* A path is printed → **record this literal string as `SYSTEM_PYTHON`** (system-level Python, used only for `setup.py`, `check_env.py`, `download_model.py`). For every command marked `[SYSTEM PYTHON]`, substitute the full literal path for `python`. Do NOT use this path for inference — inference must always use `VENV_PY`. Do NOT use a `$variable` across tool calls — each call is a new shell; always embed the literal path directly.\r
* Nothing printed → Python is not installed — install it (see below).\r
\r
**If Python is missing or outdated**, run this one-command silent installer in PowerShell (recommended, no admin required):\r
\r
```powershell\r
$f = "$env:TEMP\python-installer.exe"\r
Invoke-WebRequest "https://www.python.org/ftp/python/3.12.10/python-3.12.10-amd64.exe" -OutFile $f\r
Start-Process $f -ArgumentList "/quiet InstallAllUsers=0 PrependPath=1 Include_pip=1" -Wait\r
Remove-Item $f\r
```\r
\r
> `PrependPath=1` adds Python to PATH automatically; `Include_pip=1` installs pip; `InstallAllUsers=0` avoids requiring administrator privileges.\r
\r
After installation, **restart the terminal**, then run `python --version` and confirm it reports `Python 3.12.x`.\r
\r
If you prefer manual installation: download **https://www.python.org/ftp/python/3.12.10/python-3.12.10-amd64.exe** and make sure to check **"Add python.exe to PATH"** during setup.\r
\r
### Check git\r
\r
```bat\r
git --version\r
```\r
\r
**Interpretation:**\r
\r
| Output | Action |\r
|------|------|\r
| `git version 2.x.x` | [OK] `GIT_OK`, Pre-flight passed |\r
| `'git' is not recognized as an internal or external command` | git is not installed; install is required (see below) |\r
\r
**If git is missing**, run this one-command silent installer in PowerShell:\r
\r
```powershell\r
$f = "$env:TEMP\git-installer.exe"\r
Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v2.49.0.windows.1/Git-2.49.0-64-bit.exe" -OutFile $f\r
Start-Process $f -ArgumentList "/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=icons,ext\\reg\\shellhere,assoc,assoc_sh" -Wait\r
Remove-Item $f\r
```\r
\r
After installation, **restart the terminal**, then run `git --version` to confirm.\r
\r
If you prefer manual installation: open **https://git-scm.com/download/win**, download the installer, and proceed with default options.\r
\r
> git is required for the `git+https://` dependency in `requirements_imagegen.txt`; without git, `pip install` will fail with `git: command not found`.\r
\r
**Pre-flight pass criteria**: `python --version` is >= 3.10 and `git --version` returns a valid version string.\r
\r
Status message: `[OK] Python and git are ready. Starting main workflow.`\r
\r
---\r
\r
## Skill Contract (Input / Output)\r
\r
### Accepted Inputs\r
\r
1. **Text description** (required) — English or Chinese prompt describing the image to generate.\r
2. **Optional parameters:**\r
* `steps`: inference steps, default 9 (higher = more detail)\r
* `size`: `512×512` | `768×768` | `1024×1024`, default `512×512`\r
* `seed`: integer (default 42) or `-1` for random\r
* `output`: custom absolute output path for the PNG file\r
\r
### Output on Success\r
\r
Returns the PNG file path in stdout as `[SUCCESS] \x3Cpath>`, and sends a preview via the `message` tool.\r
\r
```json\r
{\r
"image_path": "C:\\...\\outputs\\20260412_153000_panda_bamboo.png",\r
"topic": "panda_bamboo",\r
"prompt": "A giant panda sitting in a lush bamboo forest...",\r
"steps": 9,\r
"size": "512x512",\r
"seed": 42,\r
"device": "GPU.0"\r
}\r
```\r
\r
### Output on Failure\r
\r
```json\r
{\r
"error": "human-readable description",\r
"stage": "environment | model | inference",\r
"recoverable": true\r
}\r
```\r
\r
---\r
\r
## Step 0: expand prompt (LLM only — no tools)\r
\r
Do two things simultaneously: **① expand the prompt** and **② extract a topic slug** (English snake_case, used for the filename).\r
\r
Expansion structure: `[subject] [action/pose] [environment] [lighting/mood] [style] [quality tags]`\r
\r
Prompts can be English or Chinese — no translation needed. Topic slug must always be English to avoid path encoding issues.\r
\r
Quality tags: `photorealistic`, `8K resolution`, `cinematic lighting`, `masterpiece`\r
\r
|Input|Topic slug|Expanded prompt|\r
|-|-|-|\r
|a panda|`panda_bamboo`|A giant panda sitting in a lush bamboo forest, sunlight filtering through leaves, photorealistic, 8K, wildlife photography|\r
|赛博朋克城市|`cyberpunk_city`|未来感都市夜景,霓虹灯倒映在湿漉漉的街道,赛博朋克风,电影级,8K|\r
\r
Show the result before proceeding:\r
\r
```\r
Input: {user description}\r
Expanded: {full prompt}\r
Topic: {topic_slug}\r
```\r
\r
---\r
\r
## Step 1: verify environment and model\r
\r
> Step 1/3: checking environment and model…\r
\r
```powershell\r
# [SYSTEM PYTHON] check_env.py validates the venv — must NOT use venv python here\r
python "\x3Cskill_dir>\check_env.py"\r
```\r
\r
**Output interpretation:**\r
\r
| Output | Meaning | Action |\r
|---|---|---|\r
| `MODEL_STATUS=READY` + `VENV_PY=...` | OK | Proceed to Step 2 |\r
| `SCRIPTS_STALE=old->new` | `generate_image.py` outdated | Auto-run setup.py (see below) |\r
| `STATE=MISSING` | setup.py never run | Auto-run setup.py (see below) |\r
| `VENV_PY=BROKEN` | venv corrupted | Auto-run setup.py (see below) |\r
| `PACKAGES_MISSING: ...` | packages missing from venv | Auto-run setup.py (see below) |\r
| `MODEL_STATUS=MISSING missing=[...]` | download incomplete | Auto-run download_model.py (see below) |\r
\r
**On success**: record `VENV_PY` and `IMAGE_GEN_DIR` from stdout, proceed to Step 2.\r
\r
> If `SCRIPTS_STALE` also appears alongside `MODEL_STATUS=READY`, auto-run setup.py before Step 2 (see below).\r
\r
---\r
\r
### If SCRIPTS_STALE or STATE=MISSING or VENV_PY=BROKEN or PACKAGES_MISSING → auto-run setup.py\r
\r
`SCRIPTS_STALE` means the venv and model are both OK but `generate_image.py` in `IMAGE_GEN_DIR` is an older version. `setup.py` is idempotent — it skips venv/packages if already healthy and only redeploys the script.\r
\r
`PACKAGES_MISSING` means the venv exists but required packages (`openvino`, `torch`, `optimum.intel`) are not installed. Re-running `setup.py` re-installs only what is missing.\r
\r
Announce and run (up to 3 attempts):\r
\r
```\r
[INFO] Environment not initialized — auto-installing (attempt 1/3)…\r
```\r
\r
```powershell\r
# [SYSTEM PYTHON] setup.py creates the venv — must NOT use venv python here\r
python "\x3Cskill_dir>\setup.py"\r
```\r
\r
Re-run `python "\x3Cskill_dir>\check_env.py"` after each attempt. If all 3 fail, show manual fallback below.\r
\r
---\r
\r
### If MODEL_STATUS=MISSING → auto-run download_model.py\r
\r
Announce to user and ask how to proceed:\r
\r
```\r
Model not found — download required (~10 GB)\r
Estimated time:\r
• 100 Mbps → ~15 min\r
• 50 Mbps → ~30 min\r
• 10 Mbps → ~2 hr\r
Download supports resume — safe to interrupt and retry.\r
\r
[Y] Start auto-download\r
[N] I'll download manually — show me the link\r
```\r
\r
**Auto-download** (up to 3 attempts, stop if a single attempt exceeds 20 minutes):\r
\r
```powershell\r
# [SYSTEM PYTHON] download_model.py uses stdlib only — must NOT use venv python here\r
python "\x3Cskill_dir>\download_model.py"\r
```\r
\r
Re-run `python "\x3Cskill_dir>\check_env.py"` after each attempt.\r
\r
**Manual download fallback:**\r
\r
ModelScope page: **https://modelscope.cn/models/snake7gun/Z-Image-Turbo-int4-ov/files**\r
\r
Place all files under `\x3CIMAGE_GEN_DIR>\Z-Image-Turbo-int4-ov\`. Required subdirs:\r
\r
```\r
Z-Image-Turbo-int4-ov\\r
├── transformer\\r
├── vae_decoder\\r
└── text_encoder\\r
```\r
\r
Then re-run `python "\x3Cskill_dir>\check_env.py"` to verify.\r
\r
---\r
\r
### Manual fallback (only if all 3 setup auto-attempts fail)\r
\r
Show user:\r
\r
```\r
[WARN] Auto-install failed. Please run manually in a terminal:\r
\r
1) Install environment:\r
python "\x3Cskill_dir>\setup.py"\r
Takes ~5 min, fully automated.\r
\r
2) Download model (~10 GB):\r
python "\x3Cskill_dir>\download_model.py"\r
Resumable — safe to interrupt and retry.\r
\r
Come back here when done.\r
```\r
\r
---\r
\r
## Step 2: verify dependencies\r
\r
> Step 2/3: verifying dependencies…\r
\r
**Verify dependencies** (run via VENV_PY):\r
\r
```\r
$env:PYTHONUTF8 = "1"\r
& "\x3CVENV_PY>" -c "\r
import json, site\r
from pathlib import Path\r
\r
EXPECTED_COMMITS = {\r
'optimum_intel': '2f62e5ae',\r
'diffusers': 'a1f36ee3',\r
}\r
\r
def get_git_commit(pkg_name):\r
dirs = site.getsitepackages()\r
try: dirs += [site.getusersitepackages()]\r
except Exception: pass\r
for d in dirs:\r
for dist in Path(d).glob(f'{pkg_name}*.dist-info'):\r
url_file = dist / 'direct_url.json'\r
if url_file.exists():\r
data = json.loads(url_file.read_text(encoding='utf-8'))\r
return data.get('vcs_info', {}).get('commit_id', 'no_vcs_info')\r
return 'not_found'\r
\r
results = {}\r
for pkg, imp in [('openvino','openvino'),('torch','torch'),('Pillow','PIL'),('modelscope','modelscope')]:\r
try:\r
ver = getattr(__import__(imp), '__version__', 'OK')\r
results[pkg] = ('OK', ver)\r
except ImportError as e:\r
results[pkg] = ('MISSING', str(e))\r
\r
try:\r
from optimum.intel import OVZImagePipeline\r
results['OVZImagePipeline'] = ('OK', 'importable')\r
except ImportError as e:\r
results['OVZImagePipeline'] = ('MISSING', str(e))\r
\r
for pkg_name, exp in EXPECTED_COMMITS.items():\r
actual = get_git_commit(pkg_name)\r
if actual == 'not_found':\r
results[f'{pkg_name}@commit'] = ('MISSING', 'not installed via git+https')\r
elif actual.startswith(exp):\r
results[f'{pkg_name}@commit'] = ('OK', actual[:16])\r
else:\r
results[f'{pkg_name}@commit'] = ('WRONG', f'got {actual[:16]} want {exp}...')\r
\r
all_ok = all(v[0] == 'OK' for v in results.values())\r
for k, (status, detail) in results.items():\r
icon = '[OK]' if status == 'OK' else ('[WARN]' if status == 'WRONG' else '[MISSING]')\r
print(f' {icon} {k}: {detail}')\r
print('DEP_CHECK=PASS' if all_ok else 'DEP_CHECK=FAIL')\r
"\r
```\r
\r
|Output|Action|\r
|-|-|\r
|`DEP_CHECK=PASS`|[PASS] Proceed to Step 3|\r
|`DEP_CHECK=FAIL` (MISSING)|[FAIL] Re-run `setup.py` and retry|\r
|`DEP_CHECK=FAIL` (`@commit` WRONG)|[FAIL] Force reinstall: `& "\x3CVENV_PY>" -m pip uninstall optimum-intel diffusers -y` then `& "\x3CVENV_PY>" -m pip install -r "\x3Cskill_dir>\requirements_imagegen.txt" --no-cache-dir`|\r
\r
---\r
\r
## Step 3: generate image and send preview\r
\r
> Step 3/3: running inference…\r
\r
Run these two commands separately:\r
\r
```\r
$env:PYTHONUTF8 = "1"\r
```\r
\r
```\r
& "\x3CVENV_PY>" "\x3CIMAGE_GEN_DIR>\generate_image.py" --prompt "EXPANDED_PROMPT" --topic "TOPIC" --steps 9 --seed 42\r
```\r
\r
**Pass**: stdout contains `[SUCCESS]`. Record `OUTPUT_PATH` from the `[SUCCESS]` line.\r
\r
Send preview via `message` tool:\r
\r
```\r
action: "send" filePath: "OUTPUT_PATH" message: "[OK] TOPIC"\r
```\r
\r
**Final announcement:**\r
\r
```\r
[OK] Done! Path: \x3COUTPUT_PATH>\r
Prompt: {expanded prompt}\r
steps=9, 512×512, seed=42 | device: {CPU/GPU}\r
```\r
---\r
\r
## Parameters\r
\r
|Param|Default|Notes|\r
|-|-|-|\r
|`--prompt`|required|English or Chinese|\r
|`--topic`|empty|English snake_case slug for filename|\r
|`--steps`|9|Higher = more detail; no hard limit|\r
|`--width--height`|512|512 | 768|768 1024|1024 recommended|\r
|`--seed`|42|-1 = random|\r
|`--output`|auto|Custom absolute output path|\r
\r
> `guidance_scale` is fixed at `0.0` and not exposed as a parameter.\r
\r
---\r
\r
## Troubleshooting\r
\r
|Error|Cause|Fix|\r
|-|-|-|\r
|`STATE=MISSING`|setup.py never run|Run `python "\x3Cskill_dir>\setup.py"`|\r
|`VENV_PY=BROKEN`|venv corrupted|Re-run `python "\x3Cskill_dir>\setup.py"` — rebuilds venv automatically|\r
|`PACKAGES_MISSING: ...`|venv ok but packages missing|Re-run `python "\x3Cskill_dir>\setup.py"` — reinstalls missing packages; skips steps already done|\r
|`MODEL_STATUS=MISSING`|download never run or interrupted|Run `python "\x3Cskill_dir>\download_model.py"` — resumes automatically|\r
|`DEP_CHECK=FAIL` (MISSING)|packages not installed in venv|Re-run `setup.py`|\r
|`DEP_CHECK=FAIL` (`@commit` WRONG)|PyPI release installed instead of pinned commit|Uninstall optimum-intel + diffusers, reinstall with `--no-cache-dir`|\r
|`@commit` shows `not installed via git+https`|git was missing when pip ran|Confirm git is installed, re-run `setup.py`|\r
|`[ERROR] Model incomplete`|Download interrupted mid-file|Re-run `download_model.py` — resumes automatically|\r
|`[ERROR] state.json not found`|state.json missing|Re-run Step 1|\r
|`SCRIPTS_STALE=old->new`|`generate_image.py` in `IMAGE_GEN_DIR` is outdated|Auto-run `setup.py` — it redeploys only the script, skips venv/packages/model (fast)|\r
|`RuntimeError` on GPU|Insufficient VRAM|Lower resolution or hardcode `return "CPU"` in `get_device()`|\r
|Black noisy output|Too few steps|Use `--steps` ≥ 4; 9 recommended|\r
|Download timeout|Network issue or proxy needed|Configure proxy and retry — download supports resume|\r
|`RuntimeError: stack expects each tensor to be equal size`|openvino 2026.1.0 breaks `OVZImagePipeline.forward` — `pooled_projections` tensors have mismatched sequence lengths|Downgrade: `& "\x3CVENV_PY>" -m pip install openvino==2026.0.0 --force-reinstall`. Then re-run Step 2 and Step 3. If re-running `setup.py`, it will now install the pinned version automatically.|\r
\r
\r
\r
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install local-image-gen-aipc - 安装完成后,直接呼叫该 Skill 的名称或使用
/local-image-gen-aipc触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Z-image Local image generation with OpenVINO (no API key) 是什么?
generate an image, create a picture, draw something, make an image of, text to image, paint a picture, illustrate, visualize, local image generation, AI art,... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 333 次。
如何安装 Z-image Local image generation with OpenVINO (no API key)?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install local-image-gen-aipc」即可一键安装,无需额外配置。
Z-image Local image generation with OpenVINO (no API key) 是免费的吗?
是的,Z-image Local image generation with OpenVINO (no API key) 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Z-image Local image generation with OpenVINO (no API key) 支持哪些平台?
Z-image Local image generation with OpenVINO (no API key) 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Z-image Local image generation with OpenVINO (no API key)?
由 juan-OY(@juan-oy)开发并维护,当前版本 v1.0.3。