Logo for AiToolGo

Mastering Text-to-Image in Stable Diffusion: A Complete Guide to Prompts and Parameters

In-depth discussion
Easy to understand
 0
 0
 1
本文是Stable Diffusion新手系列教程的文生图篇,系统讲解文生图的基础操作流程(选择模型、填写提示词、设置参数、生成)、提示词的概念与基本书写规范、提示词万能公式(主体内容、环境背景、构图镜头、图像设定、参考风格),以及括号权重、分步绘制、停止绘制、BREAK打断、AND融合、交替绘制、矩阵排列等高阶语法,并逐项解析采样迭代步数、采样方法、尺寸、高清修复、批次数量、CFG Scale、随机种子等常用参数。
  • main points
  • unique insights
  • practical applications
  • key topics
  • key insights
  • learning outcomes
  • • main points

    • 1
      结构完整,按'基础操作—提示词—高阶语法—参数解析'递进展开,覆盖文生图主要环节
    • 2
      提供可操作的提示词公式和语法示例(如权重括号、BREAK、AND),便于读者直接套用
    • 3
      参数讲解包含取值建议(如步数20–30、CFG保持7左右、采样算法优先级),实用性强
  • • unique insights

    • 1
      指出提示词中模型'风格由模型决定、内容由提示词决定'的分工逻辑,并建议风格需求优先选择对应风格模型而非堆砌风格词
    • 2
      解释分步/停止绘制的原理:画面主体在前约20步已基本定型,重要元素需在迭代前期开始绘制,这一观察有助于理解扩散过程
  • • practical applications

    • 对初学者而言,本文可直接指导完成第一次有控制的文生图操作,并通过权重、语法和参数调节逐步提升出图质量与稳定性,具备较高的即learn即用价值。
  • • key topics

    • 1
      Stable Diffusion文生图基础操作流程(模型、提示词、参数、生成)
    • 2
      提示词的书写规范与万能公式(主体、环境、构图、图像设定、参考风格)
    • 3
      高阶提示词语法(权重控制、分步绘制、打断/融合、交替、矩阵排列)及核心参数解析
  • • key insights

    • 1
      以'提示词万能公式'降低新手编写提示词的门槛,形成可复用的结构化方法
    • 2
      对WebUI高阶语法进行系统归纳,并结合对比示例说明每种语法的效果差异
    • 3
      对采样算法、尺寸、CFG、种子等参数给出经验性取值建议,减少新手试错成本
  • • learning outcomes

    • 1
      掌握Stable Diffusion文生图的四步操作流程(选择模型、填写提示词、设置参数、生成)
    • 2
      能够按照主体、环境、构图、图像设定、参考风格的公式编写结构化提示词,并使用权重、BREAK、AND等语法调节画面
    • 3
      理解采样步数、采样算法、尺寸、CFG Scale、随机种子及高清修复等参数的作用,并能根据需求进行基础调参
examples
tutorials
code samples
visuals
fundamentals
advanced content
practical tips
best practices

“ Introduction to Text-to-Image in Stable Diffusion

Stable Diffusion supports two main drawing modes: text-to-image (文生图) and image-to-image (图生图). This guide focuses on text-to-image, the process of generating images from written descriptions. The basic workflow has four steps: select a model, enter a prompt, configure parameters, and click generate. The final result is determined jointly by three elements. The model mainly controls the art style, the prompt mainly controls the image content, and the parameters control the preset properties of the image. All three are essential, and understanding how they interact is the foundation for consistent, high-quality output.

“ What Is a Prompt?

A prompt is the instruction that guides an AI model toward the output you want. Because AI models learn from large datasets, a simple natural-language sentence often lacks the precision needed for accurate results. Users therefore provide positive and negative feedback to steer the model's behavior. In AI image generation, the prompt acts as the bridge between human intent and model understanding. The richer and clearer the information in the prompt, the more closely the result matches expectations. Prompt design has even grown into a discipline known as Prompt Engineering, which many organizations now employ specialists to practice.

“ Basic Prompt Syntax and Writing Rules

Stable Diffusion uses two kinds of prompts. The positive prompt describes what should appear in the image, while the negative prompt specifies what should be excluded, such as distorted hands. Most models are trained on English, so prompts must be written in English. Keep the input method set to English, because the model cannot interpret Chinese characters. Prompts do not need strict grammar; write them as comma-separated phrases. Letter case and line breaks generally do not affect the result, so line breaks can be used to improve readability. The WebUI limits prompts to 75 tokens, which is measured in tokens rather than words, so one word may count as several tokens. More content is not always better: overly long prompts can create conflicting meanings and make targeted edits difficult. Even an empty prompt will generate an image, but writing well-structured prompts gives far more control over results.

“ The Universal Prompt Formula

A well-structured prompt can be organized into five categories: subject content, environment and background, composition and camera framing, image quality settings, and reference style. Subject content describes the main element, such as a person's clothing or expression, or an animal's fur or pose; it is best to keep the number of main subjects to two or fewer. Environment and background sets the scene, lighting, sky color, and overall tone to create atmosphere. Composition and camera framing adjusts viewpoint and depth of field, such as golden ratio composition, medium shot, or shallow depth of field. Image quality settings, such as fine detail, photographic quality, or cinematic feel, enhance visual richness, though final resolution is still largely determined by image size and GPU capability. Reference style describes the artistic approach or era; in Stable Diffusion, style is mostly determined by the model, so using a model trained for the desired style is usually more effective than relying on style keywords alone. These categories are a guideline rather than a requirement: start with the subject, evaluate the output, and refine from there.

“ Advanced Prompt Syntax Techniques

Keyword weighting is the most frequently used technique. Wrapping a keyword in parentheses () increases its weight to about 1.1 times, square brackets [] reduce it to about 0.9 times, and curly braces {} adjust it to about 1.05 times. Nested brackets stack their effects. Explicit values such as (blonde hair:1.2) provide more precise control, and Ctrl plus the up or down arrow keys adjusts weights quickly. Step-based blending, written as [A:B:N], switches from keyword A to keyword B after N steps, which controls how much each element influences the final image. Stopping, written as [A::N], draws keyword A first and removes it after a set proportion of steps. Prompt breaks use the keyword BREAK to separate prompt sections, reducing contamination where one element's color or feature leaks into another. The AND keyword combines adjacent keywords so the model interprets them as one concept, such as yellow AND green producing a grass green. Alternating draws, written as [A|B], alternates between two keywords at each step, producing hybrid forms such as a creature that blends features of two animals. Matrix arrays, written with the pipe syntax and used with the Prompt matrix option, generate a separate image for every combination of prompt variants in a batch.

“ Core Generation Parameters Explained

Parameters set the preset properties of the image and remove the need to control everything through prompts. Many additional control methods require extension plugins, which are covered in later tutorials. The most important parameters include sampling steps, sampler choice, face restoration, tiling, image dimensions, Hi-Res Fix, batch settings, CFG Scale, and seed. Each one affects the output in a different way, and understanding them allows precise adjustment of results.

“ Sampling Steps and Sampling Methods

Sampling steps represent the number of denoising iterations. Each step refines the image from the previous one. More steps can produce finer detail, but results usually stabilize around 30 steps, and additional steps mainly refine small details while consuming more resources. Keeping steps between 20 and 30 is recommended. Too few steps can cause incomplete drawings or distortion. The sampler determines the algorithm used for the diffusion process, and different samplers produce subtly different results. The best practice is to use the sampler recommended by the model author. Samplers with a plus sign are generally more stable. Popular and reliable choices include Euler A, DPM++ 2S a Karras, DPM++ 2M Karras, and DPM++ SDE Karras. Face restoration improves facial features and is most useful for realistic or semi-realistic portraits; many modern models already include strong face training, so enabling it may sometimes interfere. Tiling generates repeating patterns or textures and is rarely needed.

“ Image Size, Hi-Res Fix, and Batch Settings

Width and height determine the output dimensions. Larger images can contain more information and therefore more detail, but they require more GPU memory, take longer to generate, and may produce black images or memory errors. Most Stable Diffusion models are trained at 512x512 or 768x768. When dimensions deviate greatly from these, such as 1536x512, the model may interpret the canvas as several stitched images, resulting in extra people or limbs. Hi-Res Fix solves this problem by generating at a lower resolution and then performing an additional upscaling pass, which adds detail while keeping the composition stable. Batch count is the number of times generation runs with the same settings, and batch size is the number of images generated per run. The total number of images equals batch count multiplied by batch size. Batch size is usually kept at 1 because larger batches demand more VRAM; increasing batch count is the more practical way to generate multiple candidates. When multiple images are generated, the WebUI also creates a grid image combining them.

“ CFG Scale and Random Seed

CFG Scale controls how closely the image follows the prompt. Higher values make the model adhere more strictly to the prompt and reduce creative variation, while lower values give the model more freedom. The usable range is 0 to 30, but most users work between 7 and 12, and 7 is a reliable default. Values that are too low or too high can both degrade results. Generation is inherently random, and each run is associated with a seed value. Fixing the seed locks the randomness, allowing you to reproduce a satisfactory image or make controlled changes to the prompt while keeping the composition stable. Setting the seed to -1 returns to random generation, and the recycle button copies the seed of the most recent image.

“ Conclusion

Mastering text-to-image generation in Stable Diffusion requires understanding how the model, prompt, and parameters work together. Writing clear, well-organized English prompts with the universal formula gives a strong foundation, while advanced syntax such as weighting, blending, and breaks offers precise control. Adjusting sampling steps, sampler, image size, Hi-Res Fix, CFG Scale, and seed allows consistent and high-quality output. Practice and iteration remain the most effective ways to develop an intuitive sense of how each setting shapes the final image.

 Original link: https://www.craft.do/s/41OUjrfNreA3pj/b/CA89F18F-F4B6-431F-9D52-C4478E92E888/Stable-Diffusion%E5%AD%A6%E4%B9%A0%E6%8C%87%E5%8D%97%E3%80%90%E6%96%87%E7%94%9F%E5%9B%BE%E7%AF%87%E3%80%91

Comment(0)

user's avatar

      Related Tools