stable Diffusion Skill

v1.0.1

Complete Stable Diffusion WebUI integration skill. Supports txt2img, img2img, inpainting, ControlNet, LoRA, model switching, upscaling, and more via SD WebUI...

0· 108·0 current·0 all-time
byFreyr@markcookie

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for markcookie/stable-diffusion-skill.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "stable Diffusion Skill" (markcookie/stable-diffusion-skill) from ClawHub.
Skill page: https://clawhub.ai/markcookie/stable-diffusion-skill
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Required env vars: SD_WEBUI_URL
Required binaries: python
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install stable-diffusion-skill

ClawHub CLI

Package manager switcher

npx clawhub@latest install stable-diffusion-skill
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description claim a Stable Diffusion WebUI integration and the package contains a request-line CLI client (sd_client.py), prompt helper, and image utilities that call the SD WebUI API. Required binary (python) and required env var (SD_WEBUI_URL) are appropriate for this purpose.
Instruction Scope
SKILL.md instructs the agent to run the included sd_client.py and image/prompt helper scripts and to read/write image files (input images and ./sd_output by default). This is expected. One operational note: the skill will send prompts and image data to whatever SD_WEBUI_URL is set to (default localhost). If the env var is pointed at a remote/untrusted host, prompts and image data (including any images the user supplies) will be transmitted off-host.
Install Mechanism
This is instruction-only (no archive download/install). The SKILL.md recommends installing small Python deps (requests, Pillow) via pip — proportionate for the included scripts. No third-party download URLs or archive extraction are used.
Credentials
Declared required env var is SD_WEBUI_URL which is appropriate. The code also reads optional env vars SD_TIMEOUT and SD_OUTPUT_DIR (used for timeouts and output location) but these are not listed as required — this is minor but worth noting. There are no unrelated credential requests; no API keys or secrets are required by default.
Persistence & Privilege
The skill is not always-enabled, does not request elevated system privileges, and does not modify other skills. It reads and writes image files under user-specified paths or SD_OUTPUT_DIR — expected for an image-generation tool.
Assessment
This skill appears to do what it says: it contacts an SD WebUI API and reads/writes images locally. Before installing, ensure SD_WEBUI_URL points to a trusted instance (the default is http://127.0.0.1:7860). If you set SD_WEBUI_URL to a remote host, any prompts and images you send will be transmitted to that host — treat that as sensitive data. Review or run the included sd_client.py locally to confirm behavior, and run the skill in an environment where writing to the output directory is acceptable. Also note the skill expects the Python packages 'requests' and 'Pillow' to be installed. If you want stronger isolation, run the WebUI and this client on the same local machine or inside an isolated VM/container.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

🎨 Clawdis
Binspython
EnvSD_WEBUI_URL
ai-artvk971c5qdn9b268r9qdee2advzs84bfxpcontrolnetvk971c5qdn9b268r9qdee2advzs84bfxpimage-generationvk971c5qdn9b268r9qdee2advzs84bfxplatestvk971c5qdn9b268r9qdee2advzs84bfxploravk971c5qdn9b268r9qdee2advzs84bfxpstable-diffusionvk971c5qdn9b268r9qdee2advzs84bfxp
108downloads
0stars
2versions
Updated 3w ago
v1.0.1
MIT-0

🎨 Stable Diffusion Skill

通过本地部署的 Stable Diffusion WebUI API 实现完整的 AI 图像生成与编辑能力。

前提条件:需要本地安装并启动 SD WebUI(AUTOMATIC1111 版本),启动时加上 --api 参数。 默认 URL:http://127.0.0.1:7860(可通过环境变量 SD_WEBUI_URL 修改)


🚀 快速开始

检查连接状态

python ${CLAUDE_SKILL_DIR}/sd_client.py --action status

第一次使用流程

  1. 确认 SD WebUI 已运行(--api 模式)
  2. 检查连接:python ${CLAUDE_SKILL_DIR}/sd_client.py --action status
  3. 查看可用模型:python ${CLAUDE_SKILL_DIR}/sd_client.py --action list-models
  4. 生成第一张图!

📋 功能速查表

功能命令关键词说明
文生图txt2img / 生成图片 / 画从文字描述生成图像
图生图img2img / 图片风格化基于参考图生成新图
局部重绘inpaint / 修图 / 重绘修改图片特定区域
ControlNetcontrolnet / 姿势控制精确控制图像结构
超分辨率upscale / 放大 / 高清放大图片并增强细节
模型管理换模型 / 加载模型切换检查点/LoRA
批量生成批量 / batch一次生成多张变体
提示词工具优化提示词 / 翻译将中文描述转为 SD 提示词

🖼️ 文生图(txt2img)

基本用法

用户说:"帮我画一张..."、"生成一张..."、"txt2img..."

参数收集流程

  1. 如果用户没提供详细参数,先询问关键信息:
    • 描述(正向提示词)
    • 风格偏好(写实/动漫/油画等)
    • 尺寸(512x512 / 768x768 / 512x768 等)
  2. 将中文描述智能转换为 SD 提示词(见提示词转换规则)
  3. 调用 API 生成

执行命令

python ${CLAUDE_SKILL_DIR}/sd_client.py --action txt2img \
  --prompt "1girl, beautiful, masterpiece, best quality" \
  --negative-prompt "ugly, bad anatomy, blurry" \
  --width 512 --height 768 \
  --steps 20 --cfg-scale 7 \
  --sampler "DPM++ 2M Karras" \
  --seed -1 \
  --output-dir "./sd_output"

常用参数说明

参数默认值说明
--steps20采样步数(推荐 20-30)
--cfg-scale7提示词遵从度(1-30,推荐 5-12)
--samplerDPM++ 2M Karras采样器
--seed-1随机种子(-1=随机)
--width/height512x512图像尺寸(需为 8 的倍数)
--batch-size1每批生成数量
--n-iter1批次数量

🔄 图生图(img2img)

用户说:"把这张图片..."、"参考这张图风格化..."、"img2img..."

python ${CLAUDE_SKILL_DIR}/sd_client.py --action img2img \
  --init-image "/path/to/image.png" \
  --prompt "oil painting style, detailed" \
  --denoising-strength 0.75 \
  --steps 20 --cfg-scale 7 \
  --output-dir "./sd_output"

去噪强度(denoising-strength)指南

  • 0.1-0.3:轻微修改,保留原图 70-90%
  • 0.4-0.6:中度变化,半保留原始构图
  • 0.7-0.9:大幅改变,保留基本构图
  • 1.0:完全重新生成

🖌️ 局部重绘(Inpainting)

用户说:"把这张图的...改成..."、"修改图片中的..."

python ${CLAUDE_SKILL_DIR}/sd_client.py --action inpaint \
  --init-image "/path/to/image.png" \
  --mask-image "/path/to/mask.png" \
  --prompt "new content for masked area" \
  --inpainting-fill 1 \
  --denoising-strength 0.85 \
  --output-dir "./sd_output"

蒙版填充模式

  • 0:填充(fill)
  • 1:原始(original)
  • 2:潜空间噪声(latent noise)
  • 3:潜空间无(latent nothing)

🎛️ ControlNet 控制

用户说:"参考这个姿势..."、"用 ControlNet..."、"保持构图生成..."

python ${CLAUDE_SKILL_DIR}/sd_client.py --action txt2img-controlnet \
  --prompt "beautiful girl, detailed" \
  --control-image "/path/to/pose.png" \
  --control-module "openpose" \
  --control-model "control_v11p_sd15_openpose" \
  --control-weight 1.0 \
  --output-dir "./sd_output"

常用 ControlNet 模块

模块用途
openpose人体姿势控制
canny边缘线条控制
depth深度图控制
normal法线图控制
scribble手绘草图控制
seg语义分割控制
tile细节增强/高清修复
lineart线稿上色控制

🔍 超分辨率放大(Upscaling)

用户说:"放大这张图..."、"高清化..."、"超分..."

python ${CLAUDE_SKILL_DIR}/sd_client.py --action upscale \
  --image "/path/to/image.png" \
  --upscaler "R-ESRGAN 4x+" \
  --scale 2 \
  --output-dir "./sd_output"

可用放大算法(需 SD WebUI 中已安装):

  • Latent(潜空间放大,适合动漫)
  • R-ESRGAN 4x+(通用高质量)
  • R-ESRGAN 4x+ Anime6B(动漫专用)
  • ESRGAN_4x(经典ESRGAN)
  • SwinIR 4x(写实图像)

📦 模型管理

查看可用模型

python ${CLAUDE_SKILL_DIR}/sd_client.py --action list-models
python ${CLAUDE_SKILL_DIR}/sd_client.py --action list-samplers
python ${CLAUDE_SKILL_DIR}/sd_client.py --action list-upscalers
python ${CLAUDE_SKILL_DIR}/sd_client.py --action list-loras
python ${CLAUDE_SKILL_DIR}/sd_client.py --action list-vaes

切换检查点模型

python ${CLAUDE_SKILL_DIR}/sd_client.py --action switch-model \
  --model-name "realisticVisionV60B1_v60B1VAE.safetensors"

在提示词中使用 LoRA

在 prompt 中加入 <lora:模型名:权重> 语法:

1girl, beautiful, <lora:koreanDollLikeness_v15:0.8>, masterpiece

🎨 高清修复(Hires Fix)

在 txt2img 中启用 Hires Fix 生成高清大图:

python ${CLAUDE_SKILL_DIR}/sd_client.py --action txt2img \
  --prompt "landscape, detailed" \
  --width 512 --height 512 \
  --enable-hr \
  --hr-scale 2 \
  --hr-upscaler "R-ESRGAN 4x+" \
  --hr-steps 15 \
  --denoising-strength 0.5 \
  --output-dir "./sd_output"

💡 提示词转换规则

当用户用中文描述时,按以下规则转换为 SD 提示词:

标准质量词(始终添加)

正向(推荐加入):

masterpiece, best quality, ultra-detailed, high resolution

负向(推荐加入):

(worst quality:2), (low quality:2), blurry, ugly, bad anatomy, bad hands, 
extra limbs, deformed, mutated, poorly drawn face, text, watermark

风格映射

中文英文提示词
写实/真实photorealistic, ultra realistic, RAW photo
动漫/二次元anime style, 2d, cel shading
油画oil painting, painterly
水彩watercolor, soft colors
赛博朋克cyberpunk, neon lights, futuristic
古风/国风chinese traditional art, hanfu, ink wash
皮克斯风pixar style, 3d render, cartoon

翻译辅助工具

python ${CLAUDE_SKILL_DIR}/prompt_helper.py \
  --translate "美丽的中国女孩,穿着汉服,站在樱花树下" \
  --style "anime"

📊 工作流示例

示例 1:生成动漫风格人物

用户:"画一个穿着汉服的古风美女"

# 步骤1:检查模型
python ${CLAUDE_SKILL_DIR}/sd_client.py --action list-models

# 步骤2:生成图像
python ${CLAUDE_SKILL_DIR}/sd_client.py --action txt2img \
  --prompt "1girl, beautiful chinese girl, hanfu, traditional chinese clothing, cherry blossom, long hair, masterpiece, best quality, anime style" \
  --negative-prompt "(worst quality:2), (low quality:2), bad anatomy, ugly" \
  --width 512 --height 768 \
  --steps 25 --cfg-scale 7.5 \
  --sampler "DPM++ 2M Karras" \
  --output-dir "./sd_output"

示例 2:风格化照片

用户:"把这张照片变成油画风格"

python ${CLAUDE_SKILL_DIR}/sd_client.py --action img2img \
  --init-image "photo.jpg" \
  --prompt "oil painting, impressionist style, masterpiece, detailed brushwork" \
  --negative-prompt "photo, realistic, blurry" \
  --denoising-strength 0.65 \
  --steps 25 --cfg-scale 8 \
  --output-dir "./sd_output"

示例 3:批量生成变体

用户:"同一个主题生成4张不同变体"

python ${CLAUDE_SKILL_DIR}/sd_client.py --action txt2img \
  --prompt "fantasy landscape, magical forest" \
  --batch-size 4 \
  --seed -1 \
  --output-dir "./sd_output"

⚙️ 配置说明

环境变量

变量默认值说明
SD_WEBUI_URLhttp://127.0.0.1:7860SD WebUI 地址
SD_OUTPUT_DIR./sd_output默认输出目录
SD_TIMEOUT300请求超时(秒)

推荐采样器

采样器适用场景
DPM++ 2M Karras通用最佳(推荐)
DPM++ SDE Karras细节丰富
Euler a快速多样
DDIM高一致性
UniPC快速高质量

🔧 故障排除

连接失败

  • 确认 SD WebUI 已启动并带有 --api 参数
  • 检查端口是否正确(默认 7860)
  • 若使用远程服务器,检查 SD_WEBUI_URL

生成超时

  • 增大 SD_TIMEOUT 环境变量
  • 减少步数(--steps
  • 降低图像尺寸

CUDA 内存不足

  • 降低图像分辨率
  • 减少 batch size
  • 在 SD WebUI 启动时添加 --medvram--lowvram

📁 工具文件说明

文件功能
sd_client.py主 API 客户端(所有功能入口)
prompt_helper.py提示词优化与中文翻译工具
image_utils.py图像预处理工具(Base64编解码等)

⚖️ 免责声明

English: This skill is not affiliated with, endorsed by, or connected to AUTOMATIC1111 or the Stable Diffusion project in any way. It is a third-party integration tool that requires users to install SD WebUI independently. The user is solely responsible for ensuring their use of Stable Diffusion complies with applicable laws, terms of service, and licensing requirements. Generated images are subject to users' own responsibility and must comply with all relevant copyright and usage policies.

中文: 本 Skill 与 AUTOMATIC1111 或 Stable Diffusion 项目没有任何隶属、认可或关联关系。它是一个第三方集成工具,需要用户自行安装 SD WebUI。用户全权负责确保其使用 Stable Diffusion 符合适用法律、服务条款和许可要求。生成的图片由用户自行承担责任。


📜 许可证

  • 本 Skill 采用 MIT-0 License 开源(完全开放,无需署名)
  • 本 Skill 不包含 Stable Diffusion 任何源码
  • 使用本 Skill 需遵守 SD WebUI 的 AGPL-3.0 许可证

Comments

Loading comments...