“ 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.
We use cookies that are essential for our site to work. To improve our site, we would like to use additional cookies to help us understand how visitors use it, measure traffic to our site from social media platforms and to personalise your experience. Some of the cookies that we use are provided by third parties. To accept all cookies click ‘Accept’. To reject all optional cookies click ‘Reject’.
Comment(0)