Stable Diffusion API /sdapi/v1/txt2img的完整参数列表及其说明

基本参数

javascript 复制代码
{
  "prompt": "高质量,精细的恐龙",  // 主提示词
  "negative_prompt": "模糊,低质量",  // 负面提示词
  "styles": ["photorealistic", "detailed"],  // 应用的风格预设
  "seed": 42,  // 随机种子,-1为随机
  "subseed": -1,  // 次级种子
  "subseed_strength": 0.3,  // 次级种子影响强度(0-1)
  "seed_resize_from_h": -1,  // 高度方向上调整种子大小的来源
  "seed_resize_from_w": -1,  // 宽度方向上调整种子大小的来源
  "sampler_name": "DPM++ 2M Karras",  // 采样器名称
  "scheduler": "karras",  // 调度器类型
  "batch_size": 1,  // 单次生成的图像数量
  "n_iter": 1,  // 迭代次数
  "steps": 30,  // 采样步数
  "cfg_scale": 7,  // 提示词引导强度
  "distilled_cfg_scale": 3.5,  // 蒸馏模型的CFG缩放
  "width": 768,  // 图像宽度(像素)
  "height": 512,  // 图像高度(像素)
  "restore_faces": true,  // 是否使用面部恢复
  "tiling": false,  // 是否生成可平铺纹理
  "do_not_save_samples": false,  // 是否不保存样本
  "do_not_save_grid": false,  // 是否不保存网格
  "eta": 0,  // ETA参数
  "denoising_strength": 0.75,  // 去噪强度(0-1)
  "s_min_uncond": 0,  // 最小无条件缩放
  "s_churn": 0,  // 周转率
  "s_tmax": 0,  // 最大时间步长
  "s_tmin": 0,  // 最小时间步长
  "s_noise": 0,  // 噪声量
  "override_settings": {  // 临时覆盖WebUI设置
    "sd_model_checkpoint": "dreamshaper_8.safetensors",  // 模型检查点
    "CLIP_stop_at_last_layers": 2,  // CLIP层数
    "eta_noise_seed_delta": 0,  // 噪声种子增量
    "sd_vae": "vae-ft-mse-840000.safetensors"  // VAE模型
  },
  "override_settings_restore_afterwards": true,  // 处理完后是否恢复覆盖的设置
  "refiner_checkpoint": "sd_xl_refiner_1.0.safetensors",  // 细化模型检查点
  "refiner_switch_at": 0.8,  // 细化模型切换时机(0-1)
  "disable_extra_networks": false,  // 是否禁用额外网络
  "firstpass_image": "base64...",  // 第一遍图像(用于img2img)
  "comments": {  // 注释,可用于存储元数据
    "author": "用户名",
    "creation_date": "2023-10-15"
  }
}

高分辨率修复参数

javascript 复制代码
{
  "enable_hr": true,  // 是否启用高分辨率修复
  "firstphase_width": 512,  // 第一阶段宽度
  "firstphase_height": 512,  // 第一阶段高度
  "hr_scale": 2,  // 高分辨率缩放因子
  "hr_upscaler": "Latent (bicubic antialiased)",  // 高分辨率上采样器
  "hr_second_pass_steps": 20,  // 高分辨率第二阶段步数
  "hr_resize_x": 1024,  // 高分辨率调整后的宽度
  "hr_resize_y": 1024,  // 高分辨率调整后的高度
  "hr_checkpoint_name": "sd_xl_base_1.0.safetensors",  // 高分辨率使用的检查点
  "hr_additional_modules": ["photoreal"],  // 高分辨率额外模块
  "hr_sampler_name": "Euler a",  // 高分辨率采样器
  "hr_scheduler": "normal",  // 高分辨率调度器
  "hr_prompt": "",  // 高分辨率专用提示词(为空则使用普通提示词)
  "hr_negative_prompt": "",  // 高分辨率专用负面提示词
  "hr_cfg": 8,  // 高分辨率CFG值
  "hr_distilled_cfg": 3.5  // 高分辨率蒸馏CFG值
}

Always-On 脚本参数

javascript 复制代码
"alwayson_scripts": {
  "controlnet": {
    "args": [
      {
        "enabled": true,  // 是否启用
        "module": "depth",  // 控制模块类型
        "model": "diff_control_sd15_depth_fp16 [978ef0a1]",  // 模型名称
        "weight": 1.0,  // 权重
        "image": "base64...",  // Base64编码的输入图像
        "mask": "base64...",  // 遮罩(可选)
        "resize_mode": 1,  // 调整大小模式:0=只调整大小,1=裁剪匹配,2=填充匹配
        "low_vram": false,  // 低VRAM模式
        "processor_res": 512,  // 处理器分辨率
        "threshold_a": 64,  // 阈值A
        "threshold_b": 64,  // 阈值B
        "guidance_start": 0.0,  // 指导开始
        "guidance_end": 1.0,  // 指导结束
        "control_mode": 0,  // 控制模式: 0=平衡, 1=仅提示词, 2=仅控制
        "pixel_perfect": false  // 像素完美
      },
      {
        "enabled": true,  // 可以有多个ControlNet条目
        "module": "canny",
        "model": "diff_control_sd15_canny_fp16 [3b9d7d0e]",
        // ... 其他参数
      }
    ]
  }
}

脚本和系统参数

javascript 复制代码
{
  "force_task_id": "12345",  // 强制任务ID
  "sampler_index": "Euler",  // 兼容旧版本的采样器索引
  "script_name": "ultimate sd upscale",  // 脚本名称
  "script_args": [true, 64, "复杂参数"],  // 脚本参数列表
  "send_images": true,  // 是否在响应中返回图像
  "save_images": false,  // 是否保存图像到磁盘
  "infotext": "custom info text"  // 信息文本
}

ADetailer(自动细节增强)

javascript 复制代码
"alwayson_scripts": {
  "ADetailer": {
    "args": [
      {
        "enabled": true,
        "ad_model": "face_yolov8n.pt",  // 面部检测模型
        "ad_prompt": "美丽的脸,高清细节",  // 面部提示词
        "ad_negative_prompt": "模糊,变形",  // 面部负面提示词
        "ad_confidence": 0.3,  // 检测置信度
        "ad_denoising_strength": 0.4,  // 去噪强度
        "ad_inpaint_only_masked": true,  // 是否仅修补遮罩区域
        "ad_inpaint_width": 512,  // 修补宽度
        "ad_inpaint_height": 512,  // 修补高度
        "ad_mask_blur": 4,  // 遮罩模糊
        "ad_dilate_erode": 4  // 扩张/侵蚀
      }
    ]
  }
}

DynamicPrompts

javascript 复制代码
"alwayson_scripts": {
  "Dynamic Prompts": {
    "args": [
      true,  // 启用/禁用
      "强化变体策略",  // 变体策略
      true,  // 使用魔术提示
      "combinatorial",  // 组合方法
      "",  // 批次前缀
      2  // 每个提示词的变体数量
    ]
  }
}

X/Y/Z 图表

javascript 复制代码
"alwayson_scripts": {
  "X/Y/Z plot": {
    "args": [
      true,  // 启用
      "Prompt S/R",  // X类型
      "Steps",  // Y类型
      "Nothing",  // Z类型
      "cat, dog, bird",  // X值
      "10, 20, 30",  // Y值
      "",  // Z值
      true,  // 绘制图例
      true,  // 保持种子不变
      "grid"  // 绘图格式
    ]
  }
}

LoRA 块权重

javascript 复制代码
"alwayson_scripts": {
  "LoRA Block Weight": {
    "args": [
      true,  // 启用
      {
        "lora_name": "my_lora",
        "base_model_weights": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        "base_model_multipliers": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
      }
    ]
  }
}

完整示例

javascript 复制代码
{
  "prompt": "高质量,精细的恐龙,逼真的鳞片和肌肉细节,自然栖息地",
  "negative_prompt": "模糊,低质量,变形,扭曲的解剖结构",
  "styles": ["photorealistic"],
  "seed": 42,
  "subseed": -1,
  "subseed_strength": 0,
  "seed_resize_from_h": -1,
  "seed_resize_from_w": -1,
  "sampler_name": "DPM++ 2M Karras",
  "scheduler": "karras",
  "batch_size": 1,
  "n_iter": 1,
  "steps": 30,
  "cfg_scale": 7,
  "distilled_cfg_scale": 3.5,
  "width": 768,
  "height": 512,
  "restore_faces": true,
  "tiling": false,
  "do_not_save_samples": false,
  "do_not_save_grid": false,
  "eta": 0,
  "denoising_strength": 0,
  "s_min_uncond": 0,
  "s_churn": 0,
  "s_tmax": 0,
  "s_tmin": 0,
  "s_noise": 0,
  "override_settings": {
    "sd_model_checkpoint": "F.1-fp8_11G版_flux1-Schnell.safetensors",
    "CLIP_stop_at_last_layers": 2
  },
  "override_settings_restore_afterwards": true,
  "refiner_checkpoint": "sd_xl_refiner_1.0.safetensors",
  "refiner_switch_at": 0.8,
  "disable_extra_networks": false,
  "comments": {},
  "enable_hr": false,
  "firstphase_width": 0,
  "firstphase_height": 0,
  "hr_scale": 2,
  "hr_upscaler": "Latent (bicubic antialiased)",
  "hr_second_pass_steps": 20,
  "hr_resize_x": 0,
  "hr_resize_y": 0,
  "hr_checkpoint_name": "",
  "hr_additional_modules": [],
  "hr_sampler_name": "",
  "hr_scheduler": "",
  "hr_prompt": "",
  "hr_negative_prompt": "",
  "hr_cfg": 0,
  "hr_distilled_cfg": 3.5,
  "force_task_id": "",
  "sampler_index": "Euler",
  "script_name": "",
  "script_args": [],
  "send_images": true,
  "save_images": false,
  "alwayson_scripts": {
    "controlnet": {
      "args": [
        {
          "enabled": true,
          "module": "depth",
          "model": "diff_control_sd15_depth_fp16 [978ef0a1]",
          "weight": 1.0,
          "image": "base64...",
          "resize_mode": 1,
          "low_vram": false,
          "processor_res": 512,
          "threshold_a": 64,
          "threshold_b": 64,
          "guidance_start": 0.0,
          "guidance_end": 1.0,
          "control_mode": 0,
          "pixel_perfect": false
        }
      ]
    },
    "ADetailer": {
      "args": [
        {
          "enabled": true,
          "ad_model": "face_yolov8n.pt",
          "ad_prompt": "",
          "ad_negative_prompt": "",
          "ad_confidence": 0.3,
          "ad_denoising_strength": 0.4
        }
      ]
    }
  }
}
相关推荐
Liudef064 小时前
文生图技术的演进、挑战与未来:一场重构人类创造力的革命
人工智能·stable diffusion·重构
莫扎特不唱摇篮曲9 小时前
stable-diffusion-webui-docker 构建 comfy-ui
docker·stable diffusion·comfy
Z_W_H_2 天前
【AI】Stable Diffusion安装
人工智能·stable diffusion
Liudef062 天前
Stable Diffusion游戏底模推荐
游戏·stable diffusion
德育处主任4 天前
『ComfyUI』初识工作流
人工智能·stable diffusion·aigc
AIGC龙哥5 天前
Stable Diffusion教程|快速入门SD绘画原理与安装
stable diffusion·aigc·ai绘画·sd·安装包·本地部署·炼丹师
JokerSZ.5 天前
复现:latent diffusion(LDM)stable diffusion
人工智能·深度学习·stable diffusion·生成模型
莫扎特不唱摇篮曲6 天前
dify + ollama + deepseek-r1+ stable-diffusion 构建绘画智能体
stable diffusion
Liudef068 天前
国内支持Stable Diffusion模型的平台
ai作画·stable diffusion·人工智能作画